needs

1.0.4 • Public • Published

Needs

NPM Version Build Status Coverage Quality Dependencies

Require multiple modules in node.js.

Installation

$ npm install needs --save

Usage

RegExp pattern

var needs = require('needs');
 
needs(__dirname, 'controllers', {
    includes: /(.+Controller)\.js$/,
    excludes: /^\.(git|svn)$/
});
 
// controllers now is an object with references to all modules matching the filter
// for example:
// { HomeController: function HomeController() {...}, ...}
 

Minimatch string pattern

// or using minimatch string
needs(__dirname, 'controllers', {
    includes: '+(*.js|*.json)',
    excludes: '+(*.git|*.svn)'
});

Array includes and excludes

needs(__dirname, 'controllers', {
    includes: ['*.js', '*.json'],
    excludes: ['*.git', '*.svn']
});

Array pattern

needs(__dirname, 'controllers', ['*.js', '*.json']);

Simplest way to include and exclude

needs(__dirname, 'controllers', ['*.js', '*.json', '!*.git', '!*.svn']);
 
// or default includes ['*.js', '*.json'] and excludes ['!*.git', '!*.svn']
needs(__dirname, 'controllers');

Links

License

Copyright (c) 2014 Tao Yuan Licensed under the MIT license.

Package Sidebar

Install

npm i needs

Weekly Downloads

24

Version

1.0.4

License

MIT

Last publish

Collaborators

  • bitt