From 7cbe429be9d531844d3b28587b88a284fe2cc27e Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Sun, 1 Sep 2013 15:27:45 -0400 Subject: [PATCH] fixing issue with plugins trying to load 0 plugins and crashing --- src/plugins.js | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/plugins.js b/src/plugins.js index 4a4772ff57..9e6885628b 100644 --- a/src/plugins.js +++ b/src/plugins.js @@ -18,17 +18,19 @@ var fs = require('fs'), RDB.smembers('plugins:active', next); }, function(plugins, next) { - async.each(plugins, function(plugin) { - // TODO: Update this check to also check node_modules - var pluginPath = path.join(__dirname, '../plugins/', plugin), - modulePath = path.join(__dirname, '../node_modules/', plugin); - if (fs.existsSync(pluginPath)) _self.loadPlugin(pluginPath, next); - else if (fs.existsSync(modulePath)) _self.loadPlugin(modulePath, next); - else { - if (global.env === 'development') winston.info('[plugins] Plugin \'' + plugin + '\' not found'); - next(); // Ignore this plugin silently - } - }, next); + if (plugins.length > 0) { + async.each(plugins, function(plugin) { + // TODO: Update this check to also check node_modules + var pluginPath = path.join(__dirname, '../plugins/', plugin), + modulePath = path.join(__dirname, '../node_modules/', plugin); + if (fs.existsSync(pluginPath)) _self.loadPlugin(pluginPath, next); + else if (fs.existsSync(modulePath)) _self.loadPlugin(modulePath, next); + else { + if (global.env === 'development') winston.info('[plugins] Plugin \'' + plugin + '\' not found'); + next(); // Ignore this plugin silently + } + }, next); + } else next(); } ], function(err) { if (err) {