refactor: add method to get directly property

This commit is contained in:
Iuri Matias 2017-12-29 08:08:04 -05:00
parent 8956992950
commit 4c1adf258b
2 changed files with 14 additions and 9 deletions

View File

@ -74,7 +74,6 @@ Config.prototype.loadBlockchainConfigFile = function() {
}; };
Config.prototype.loadContractsConfigFile = function() { Config.prototype.loadContractsConfigFile = function() {
var configObject = { var configObject = {
"default": { "default": {
"versions": { "versions": {
@ -96,14 +95,10 @@ Config.prototype.loadContractsConfigFile = function() {
} }
}; };
var configPlugins = this.plugins.getPluginsFor('contractsConfig'); var contractsConfigs = this.plugins.getPluginsProperty('contractsConfig', 'contractsConfigs');
if (configPlugins.length > 0) { contractsConfigs.forEach(function(pluginConfig) {
configPlugins.forEach(function(plugin) { configObject = utils.recursiveMerge(configObject, pluginConfig);
plugin.contractsConfigs.forEach(function(pluginConfig) { });
configObject = utils.recursiveMerge(configObject, pluginConfig);
});
});
}
var contractsConfig; var contractsConfig;
if (fs.existsSync(this.configDir + "contracts.json")) { if (fs.existsSync(this.configDir + "contracts.json")) {

View File

@ -51,4 +51,14 @@ Plugins.prototype.getPluginsFor = function(pluginType) {
}); });
}; };
Plugins.prototype.getPluginsProperty = function(pluginType, property) {
let matchingPlugins = this.plugins.filter(function(plugin) {
return plugin.has(pluginType);
});
return matchingPlugins.map((plugin) => {
return plugin[property];
});
};
module.exports = Plugins; module.exports = Plugins;