require-plugins
v1.0.3
Published
This module loads modules for a "pluggable" node project
Downloads
9
Maintainers
Readme
require-plugins
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