refactor; flatten property list

This commit is contained in:
Iuri Matias 2017-12-29 08:26:31 -05:00
parent 4c1adf258b
commit f00fa1c4aa
2 changed files with 9 additions and 11 deletions

View File

@ -10,16 +10,10 @@ class Compiler {
compile_contracts(contractFiles, cb) { compile_contracts(contractFiles, cb) {
let available_compilers = {}; let available_compilers = {};
if (this.plugins) { let pluginCompilers = this.plugins.getPluginsProperty('compilers', 'compilers');
let compilerPlugins = this.plugins.getPluginsFor('compilers'); pluginCompilers.forEach(function (compilerObject) {
if (compilerPlugins.length > 0) {
compilerPlugins.forEach(function (plugin) {
plugin.compilers.forEach(function (compilerObject) {
available_compilers[compilerObject.extension] = compilerObject.cb; available_compilers[compilerObject.extension] = compilerObject.cb;
}); });
});
}
}
let compiledObject = {}; let compiledObject = {};

View File

@ -56,9 +56,13 @@ Plugins.prototype.getPluginsProperty = function(pluginType, property) {
return plugin.has(pluginType); return plugin.has(pluginType);
}); });
return matchingPlugins.map((plugin) => { let matchingProperties = matchingPlugins.map((plugin) => {
return plugin[property]; return plugin[property];
}); });
//return flattened list
if (matchingProperties.length === 0) return [];
return matchingProperties.reduce((a,b) => { return a.concat(b); })
}; };
module.exports = Plugins; module.exports = Plugins;