@webgap/require-utils
v0.0.1
Published
Automatically requires modules with a specific pattern from a specific directory.
Downloads
5
Maintainers
Readme
WebGAP Require Utils
README
This is an utility tool to load multiple node.js modules in parallel.
Dependencies
Handles files/ folders search using fs-finder. Handles async implementation using async.
API
Installation
npm install @webgap/require-utils --save
Usage
If you want to load module files from a specific directory:
var req = require('../index').require;
req({
"require": [{
"directories": ['path/to/lib'],
"pattern": 'auth-*.js'
}]
}, function afterRequire(err, modules) {
assert.equal(err, undefined);
assert.notEqual(err, modules);
done();
});
If you want to load modules from a specific directory:
req({
"require": [{
"directories": ['path/to/modules'],
"pattern": 'auth-*'
}]
}, function afterRequire(err, modules) {
assert.equal(err, undefined);
assert.notEqual(err, modules);
done();
});
Check tests folder.
License
Apache License, Version 2.0