From f00fa1c4aa4d24e4c711215631a598b77d82e6ff Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 29 Dec 2017 08:26:31 -0500 Subject: [PATCH] refactor; flatten property list --- lib/contracts/compiler.js | 14 ++++---------- lib/core/plugins.js | 6 +++++- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/lib/contracts/compiler.js b/lib/contracts/compiler.js index 054e6bf2..a453a8a1 100644 --- a/lib/contracts/compiler.js +++ b/lib/contracts/compiler.js @@ -10,16 +10,10 @@ class Compiler { compile_contracts(contractFiles, cb) { let available_compilers = {}; - if (this.plugins) { - let compilerPlugins = this.plugins.getPluginsFor('compilers'); - if (compilerPlugins.length > 0) { - compilerPlugins.forEach(function (plugin) { - plugin.compilers.forEach(function (compilerObject) { - available_compilers[compilerObject.extension] = compilerObject.cb; - }); - }); - } - } + let pluginCompilers = this.plugins.getPluginsProperty('compilers', 'compilers'); + pluginCompilers.forEach(function (compilerObject) { + available_compilers[compilerObject.extension] = compilerObject.cb; + }); let compiledObject = {}; diff --git a/lib/core/plugins.js b/lib/core/plugins.js index 3ac88052..83a5bd34 100644 --- a/lib/core/plugins.js +++ b/lib/core/plugins.js @@ -56,9 +56,13 @@ Plugins.prototype.getPluginsProperty = function(pluginType, property) { return plugin.has(pluginType); }); - return matchingPlugins.map((plugin) => { + let matchingProperties = matchingPlugins.map((plugin) => { return plugin[property]; }); + + //return flattened list + if (matchingProperties.length === 0) return []; + return matchingProperties.reduce((a,b) => { return a.concat(b); }) }; module.exports = Plugins;