req-dir
v0.0.5
Published
require all files from a path
Downloads
6
Readme
This module require all files from a directory (only .json, .js, and .coffee), inside a path you want, and return a object with this modules.
Usage
First install
npm i --save req-dir
And in your files, use:
var reqDir = require('req-dir');
var path = '.'; // path to dir, in this case, same directory
var controllers = reqDir(path);
Other examples:
var controllers = reqDir('./controllers');
var controllers = reqDir('../controllers');
Important
The path is relative to the file that calls the reqDir.
Tests
I use mocha for tests, first install mocha as global
npm i -g mocha
Then run tests with:
npm test
Enjoy!