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() {
var configObject = {
"default": {
"versions": {
@ -96,14 +95,10 @@ Config.prototype.loadContractsConfigFile = function() {
}
};
var configPlugins = this.plugins.getPluginsFor('contractsConfig');
if (configPlugins.length > 0) {
configPlugins.forEach(function(plugin) {
plugin.contractsConfigs.forEach(function(pluginConfig) {
configObject = utils.recursiveMerge(configObject, pluginConfig);
});
});
}
var contractsConfigs = this.plugins.getPluginsProperty('contractsConfig', 'contractsConfigs');
contractsConfigs.forEach(function(pluginConfig) {
configObject = utils.recursiveMerge(configObject, pluginConfig);
});
var contractsConfig;
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;