Import all modules in a directory
This module is intentionally simple. Not interested in more features.
$ npm install --save import-modules
.
└── dir
├── foo-bar.js
└── baz-faz.js
const importModules = require('import-modules');
const modules = importModules('dir');
console.log(modules);
//=> {fooBar: [Function], bazFaz: [Function]}
Type: string
Default: __dirname
Directory to import modules from. Does not recurse. Ignores the caller file and files starting with .
or _
.
Type: Object
Type: boolean
Default: true
Convert dash-style names (foo-bar
) to camel-case (fooBar
).
Type: array
Default: ['.js', '.json', '.node']
Module extensions white list.
- import-from - Import a module from a given path
- import-cwd - Import a module from the current working directory
- import-lazy - Import a module lazily
MIT © Sindre Sorhus