0.0.2 • Published 6 years ago

require-node-glob v0.0.2

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

require-node-glob

Yet another require-all variant. Sadly I didn't find one that:

  • works for relative/absolute urls
  • works for modules
  • returning an array

Import an array of node modules, using globbing and require.resolve.

const requireGlob = require('require-node-glob');

const locals = requireGlob('./services/*.js'); // if you start with ./ they are local modules

const abs = requireGlob('/home/sithmel/services/*.js'); // if you start with / they are absolute urls

const decorators = requireGlob('async-deco/src/*.js'); // in this case it will resolve from the package "async-deco"

const decorators = requireGlob(['./services/*.js', 'module1/services/*.js']); // you can use an array to include multiple globs