From 513cf2c8e237308e0cf12c89ad91ccd8a864ba1b Mon Sep 17 00:00:00 2001 From: Antonin Stefanutti Date: Thu, 9 Jul 2015 20:19:36 +0200 Subject: [PATCH] Plugins loading function uses reduce instead of forEach --- decktape.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/decktape.js b/decktape.js index 15beac5..a2c427b 100644 --- a/decktape.js +++ b/decktape.js @@ -112,15 +112,12 @@ page.open(options.url, function(status) { }); function loadAvailablePlugins() { - var plugins = {}; - fs.list("plugins/").forEach(function(script) { - if (fs.isFile("plugins/" + script)) { - var matches = script.match(/^(.*)\.js$/); - if (matches) - plugins[matches[1]] = require("./plugins/" + matches[1]); - } - }); - return plugins; + return fs.list("plugins/").reduce(function(plugins, plugin) { + var matches = plugin.match(/^(.*)\.js$/); + if (matches && fs.isFile("plugins/" + plugin)) + plugins[matches[1]] = require("./plugins/" + matches[1]); + return plugins; + }, {}); } function createActivePlugin() {