Plugins loading function uses reduce instead of forEach

This commit is contained in:
Antonin Stefanutti 2015-07-09 20:19:36 +02:00
parent 3f06784c5f
commit 513cf2c8e2

View File

@ -112,15 +112,12 @@ page.open(options.url, function(status) {
}); });
function loadAvailablePlugins() { function loadAvailablePlugins() {
var plugins = {}; return fs.list("plugins/").reduce(function(plugins, plugin) {
fs.list("plugins/").forEach(function(script) { var matches = plugin.match(/^(.*)\.js$/);
if (fs.isFile("plugins/" + script)) { if (matches && fs.isFile("plugins/" + plugin))
var matches = script.match(/^(.*)\.js$/);
if (matches)
plugins[matches[1]] = require("./plugins/" + matches[1]); plugins[matches[1]] = require("./plugins/" + matches[1]);
}
});
return plugins; return plugins;
}, {});
} }
function createActivePlugin() { function createActivePlugin() {