JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 40256
  • Score
    100M100P100Q170761F
  • License MIT

An easy way to include all (or require all) files within a directory. Note: This is a fork of felixge's require-all which returns false instead of throwing an error if the directory doesn't exist. This allows for optional includes, and relieves you from having to wrap the call to require-all in a try/catch.

Package Exports

  • include-all

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (include-all) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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 a call to include-all as optional.

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) {...}, ...}


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', ...}, ...}