Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

include-all

Package Overview
Dependencies
Maintainers
2
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

include-all

An easy way to include all node.js modules within a directory. This is a fork of felixge's awesome module, require-all (https://github.com/felixge/node-require-all) which adds the ability to mark an include as **optional**.

  • 0.1.6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
23K
decreased by-45.77%
Maintainers
2
Weekly downloads
 
Created
Source

include-all

An easy way to include all node.js modules within a directory.

This is a fork of felixge's awesome module, require-all (https://github.com/felixge/node-require-all) which adds a few extra capabilities:

  • the ability to include-all a directory as optional.
  • the ability to recursively stat a directory, instead of actually requiring the modules (via the dontLoad option)
  • the ability to filter by path, not just filename (pathFilter)

Usage


var controllers = require('include-all')({
  dirname     :  __dirname + '/controllers',
  filter      :  /(.+Controller)\.js$/,
  excludeDirs :  /^\.(git|svn)$/
});

// controllers now is an object with references to all modules matching the filter
// for example:
// { HomeController: function HomeController(req, res) {...}, ...}


### Optional include
var models = require('include-all')({
  dirname     :  __dirname + '/models',
  filter      :  /(.+)\.js$/,
  excludeDirs :  /^\.(git|svn)$/,
  optional    :  true
});

// models now is an object with references to all modules matching the filter
// but if __dirname + /models doesn't exist, instead of throwing an error, {} is returned
// for example:
// { User: { attributes: {}, adapter: 'dirty', ...}, ...}

Filter by filepath

var models = require('include-all')({ dirname : __dirname + '/controllers', filterPath : /(.+)/(.+).js$/, excludeDirs : /^.(git|svn)$/ });

Keywords

FAQs

Package last updated on 10 Mar 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc