Require the first module that matches in a set of directories
A utility library to help finding and requiring modules. Given a set of paths to look in, the module will find the first requireable match and require it.
Usage
$ npm install --save require-first
var requireFirst = 'require-first'; var dir = 'path/to/root' var f1 = requireFirst; // f1 will be the exported value of the file 'path/to/root/dir1/file1.js' if it exists,// othwrwise it will be the the value exported by 'path/to/root/dir1/file1.js'
You can also require all the modules found in a set of directories but only the first of each filename will be loaded.
var requireFirst = 'require-first'; var dir = 'path/to/root' var f = requireFirst; // f will be an objecy with a key for each file found in both dir1 and dir2// The first name match for each file will be the only one required