node package manager
We need your input. Help make JavaScript better: Take the 2017 JavaScript Ecosystem survey »


Easy Folderator

An easy way to automatically include and name modules in subdirectories.


npm install easy-folderator


Easy Folderator makes use of promises.

Lets say we have the following directory structure:


The folderator.createPackage function will return an object with the following structure:

var package = {
    innerFolder: {
        deeperInnerFolder {
            deeperInnerTestModule: /* module.exports of deeper-inner-test-module.js */
        innerTestModule: /* module.exports of inner-test-module.js */
    testModule: /* module.exports of test-module.js */


This example uses the same folder structure as above under Usage. lets say we have a folder called models with the following structure:


Let's also say that the exports object of each model is simply this:

module.exports = __filename;

Now lets look at what will happen:

var path = require('path');
var folderator = require('easy-folderator');
var packagePath = path.join(__dirname, 'models');
        rootDir: packagePath, // a required option 
        captializeModules: true
    .then(function (pack) {
        // logs: 
        // /path/to/file/models/user.js 


Options are passed to the createPackage function via an object:

        rootDir: myPath

Only rootDir is required. There are no default options so you must always pass an object with rootDir set to a string in order for the it to work.

  • rootDir required
    • rootDir is a required option that tells which folder to package up.
  • captializeModules
    • captializeModules is not required. When a js file is required it will capitalize it when it attaches it to the packed object if this is set to true.