0.4.1 • Published 9 years ago
requireables v0.4.1
requireables
Retrieves all the modules from within a target directory as an array paths that can each be used in a
require(...)
call that occurs from a specific calling directory
Installation
$ npm install requireables --save
Usage
var requireables = require('requireables');
var targetDir = '/some/target/modules/dir';
var callingDir = '/some/calling/dir'
var mods = [];
var paths = requireables.in(targetDir).from(callingDir);
paths.forEach(function(path){
mods.push(require(path));
});
// 'mods'' will now contain an array of instances of all the modules in 'targetDir'
To asynchronously run requireables
, you can use asyncly
asyncly.get(requireables.in(targetDir).from, callingDir).then(function(paths) {
console.log(paths);
);