index-require

1.0.1 • Public • Published

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`);

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i index-require

      Weekly Downloads

      1,995

      Version

      1.0.1

      License

      MIT

      Unpacked Size

      2.3 kB

      Total Files

      3

      Last publish

      Collaborators

      • omrilotan