npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@tubu/folder-builder

v1.1.3

Published

Easy way to build folder

Readme

Travis (.org) branch AppVeyor branch GitHub release (latest by date) Node version codecov dependencies Status GitHub issues

Easy way to build folder structure for node.js


const FolderBuilder = require('@tubu/folder-builder');

// Create a new FolderBuilder instance with path
const fb = new FolderBuilder(__dirname);

// Create a new folder instance with name
const newFolder = fb.createFolder('ex1');


// Build a new folder
newFolder.build(newFolder).catch(console.error);

It helps you to create files and folders easily. It can create files inside other folders recursively. Can create, delete, update files and or folders at the same time. Add this to your package.json file and it is ready to use.

Installation

Available on npm registry as a node.js module

node version > 10.16.0

To install this package

$ npm install @tubu/folder-builder

Or

$ yarn add @tubu/folder-builder

Get Started

FolderBuilder is used to create a new folder management system.

new FolderBuilder(__dirname);

Constructor Parameters

String -> Folder default path

Object -> Folder and File default Options

Example:

new FolderBuilder({
    "defaultFolder": {
                "name" : "sample",
                "path" : __dirname  
            },
    "defaultFile": {
                "mode" : 0o555
            }
    });

Main Folder Builder Methods


createFolder

fb.createFolder(folder)

Returns a new folder instance

Parameters

String -> Folder Name

Object -> Folder Options


createFile

const newFolder = fb.createFile(file)

Returns a new file instance

Parameters

String -> Folder Name

Object -> File Options


Folder

Folder instance for management folder works

Folder Options
 fb.createFolder({
    name : 'sample',
    path : __dirname,
    force : false,
    archive : false
})
  • name : Folder name (required)
  • path : Path to build current folder
  • force : Force to build folder, delete if exists
  • archive : Generate a zip file of current folder, current path

Folder Methods


addFolder

Add a child folder into the current folder, and return a new folder instance

newFolder.addFolder(folder)

Parameters

String -> Folder Name

Object -> Folder Options


addFile

Add a child file into the current folder, return a new file instance

newFolder.addFile(folder)

Parameters

String -> File Name

Object -> Folder Options


build

Build the folder with its children as folders and files, recursively.

Also, create zip files if archive of the folder is true

newFolder.build()


File

File instance for management file works

File Options

Options

 fb.createFile({
    name : 'sample.txt',
    content : 'hello',
    mode : 0o666
})
  • name : File name
  • content : Content of file
  • contentUrl : A file path to read and fill the content
  • mode : File permissions, for detail

Warning : If content is not empty, contentUrl will not be used Warning : To insert the content into the file during building process, mode must include Write Permission

File Methods


Read

Read the contentUrl path and fill the current file content,

newFile.read(contentUrl)

Parameters

contentUrl -> A path to read file to file the current file content

if contentUrl parameter is empty, it uses current file contentUrl Example:

const FolderBuilder = require('@tubu/folder-builder');

// Create a new FolderBuilder instance with path
const fb = new FolderBuilder(__dirname);

// Create a new file instance with name
const newFile = fb.createFile("sample.txt");

// Assume that `sample.txt` contains 'Hello' 
const readFile = newFile.read('/sample/sample.txt');

// It prompts 'Hello'
console.log(readFile.content);

render

Render the current file content, and return rendered file instance

newFile.render(renderObj)

Parameters

Object -> Key-Value to render object inside the current file content, it uses $[key] to refer a key inside the current file content

Example

const FolderBuilder = require('@tubu/folder-builder');

// Create a new FolderBuilder instance with path
const fb = new FolderBuilder(__dirname);

// Create a new folder instance with name
const newFolder = fb.createFolder('ex5');

// Create a new file with template format by using $[key]
const newFileTemplate = fb.createFile({
  name: 'sample.sh',
  content: `#!/bin/bash
  echo hello, $[name]
  
  if [ $[age] -gt 18 ]
  then
    echo You $[name]! You are adult.
  fi  
  
  `,
  mode: 0o555,
});

// Basic render created template
const renderedNewFile = newFileTemplate.render({
  name: 'FolderBuilder User',
  age: 21,
});

// Adding a rendered bash file into created folder
newFolder.addFile(renderedNewFile);

// Build a new folder
newFolder.build().catch(console.error);

// So, it will be executed
// ./ex5/sample.sh
// -> hello from FolderBuilder User
// -> You FolderBuilder User! You are adult

Examples

For more examples, look at examples folder .


License

MIT