node: allow non-string plugins in config.

This commit is contained in:
Christopher Jeffrey 2017-06-28 02:47:05 -07:00
parent 09d41d32a2
commit 3763b5309a
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -381,18 +381,18 @@ Node.prototype.require = function require(name) {
Node.prototype.loadPlugins = function loadPlugins() {
var plugins = this.config.array('plugins', []);
var loader = this.config.func('loader');
var i, name, plugin;
var i, plugin;
if (!loader)
return;
for (i = 0; i < plugins.length; i++) {
name = plugins[i];
plugin = plugins[i];
assert(typeof name === 'string',
'Plugin name must be a string.');
assert(plugin);
plugin = loader(name);
if (typeof plugin === 'string')
plugin = loader(plugin);
this.use(plugin);
}