require-plugins

1.0.3 • Public • Published

require-plugins

License NPM version Dependency Status

This module loads modules for a "pluggable" node project

Usage

npm install require-plugins

The plugins have to be named as the main project with a dash as separator. Example Structure:

project
    |- node_modules
        |- project-plugin1
        |- project-plugin2

require-plugins will then require all plugins starting with project- and calls their constructor with the arguments you supplied.

var plugins = require('require-plugins')(arg1, arg2, ...);

The variable plugins will afterwards contain the return values of the individual plugins constructors:

{
  'project-plugin1': require('project-plugin1')(arg1, arg2, ...),
  'project-plugin2': require('project-plugin2')(arg1, arg2, ...)
}

Note: if you don't supply any arguments to the require-plugins constructor plugins are required without calling a constructor.

So

var plugins = require('require-plugins')();

will resolve to

{
  'project-plugin1': require('project-plugin1'),
  'project-plugin2': require('project-plugin2')
}

License

MIT (c) 2016 Sebastian Raff

Package Sidebar

Install

npm i require-plugins

Weekly Downloads

2

Version

1.0.3

License

MIT

Last publish

Collaborators

  • hobbyquaker