req-dir

0.0.5 • Public • Published

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!

Readme

Keywords

Package Sidebar

Install

npm i req-dir

Weekly Downloads

3

Version

0.0.5

License

none

Last publish

Collaborators

  • darlanmendonca