diff --git a/src/plugins/load.js b/src/plugins/load.js index 2b597d7a2b..cf3340fafd 100644 --- a/src/plugins/load.js +++ b/src/plugins/load.js @@ -43,7 +43,7 @@ module.exports = function (Plugins) { Plugins.lessFiles.length = 0; Plugins.clientScripts.length = 0; Plugins.acpScripts.length = 0; - + async.waterfall([ async.apply(Plugins.getPluginPaths), function (paths, next) { @@ -195,25 +195,19 @@ module.exports = function (Plugins) { } function mapClientSideScripts(pluginData, callback) { - if (Array.isArray(pluginData.scripts)) { - if (global.env === 'development') { - winston.verbose('[plugins] Found ' + pluginData.scripts.length + ' js file(s) for plugin ' + pluginData.id); - } - - Plugins.clientScripts = Plugins.clientScripts.concat(pluginData.scripts.map(function (file) { - return resolveModulePath(path.join(__dirname, '../../node_modules/', pluginData.id, file), file); - })).filter(Boolean); - } + function mapScripts(scripts, globalScripts) { + if (Array.isArray(scripts) && scripts.length) { + if (global.env === 'development') { + winston.verbose('[plugins] Found ' + scripts.length + ' js file(s) for plugin ' + pluginData.id); + } - if (Array.isArray(pluginData.acpScripts)) { - if (global.env === 'development') { - winston.verbose('[plugins] Found ' + pluginData.acpScripts.length + ' ACP js file(s) for plugin ' + pluginData.id); + globalScripts = globalScripts.concat(scripts.map(function (file) { + return resolveModulePath(path.join(__dirname, '../../node_modules/', pluginData.id, file), file); + })).filter(Boolean); } - - Plugins.acpScripts = Plugins.acpScripts.concat(pluginData.acpScripts.map(function (file) { - return resolveModulePath(path.join(__dirname, '../../node_modules/', pluginData.id, file), file); - })).filter(Boolean); } + mapScripts(pluginData.scripts, Plugins.clientScripts); + mapScripts(pluginData.acpScripts, Plugins.acpScripts); callback(); }