Nonvoluntary Professional Mangling

npm

Need private packages and team management tools?Check out npm Orgs. »

index-require

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

Keywords

none

install

npm i index-require

Downloadsweekly downloads

881

version

1.0.0

license

MIT

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability