tarima
Version:
Templating madness!
29 lines (22 loc) • 592 B
JavaScript
;
module.exports = (plugins, options) => {
options = options || {};
if (!Array.isArray(plugins) && typeof plugins === 'object') {
plugins = Object.keys(plugins).map(key => {
options[key] = plugins[key];
return key;
});
}
return plugins.map(plugin => {
if (typeof plugin === 'string') {
/* eslint-disable global-require */
const Plugin = require(plugin);
if (typeof Plugin === 'function') {
plugin = new Plugin(options[plugin] || {});
} else {
plugin = Plugin;
}
}
return plugin;
});
};