index-require
v1.0.1
Published
☝️ Create an index for a lib directory
Downloads
11,549
Readme
index-require
☝️ Create an index for a lib directory
Scan directory for nested directories and create an index module
Tree
├── main.js
└── lib
├── index.js
├── module1
│ ├── index.js
│ └── spec.js
└── module2
├── index.js
└── spec.js
lib/index.js
const inedx = require('index-require');
module.exports = inedx(__dirname);
main.js
const {module1, module2} = require('./lib');
App with features structure
app.js
├── app.js
├── feature1
│ ├── index.js
│ └── spec.js
└── feature2
├── index.js
└── spec.js
app.js
const inedx = require('index-require');
const {
feature1,
feature2,
} = inedx(__dirname);
Optional second argument for different structures
const inedx = require('index-require');
module.exports = inedx(__dirname, name => `./${name}/main.js`);