refactor: add method to get directly property
This commit is contained in:
parent
8956992950
commit
4c1adf258b
|
@ -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")) {
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue