redeploy with right config on config change

This commit is contained in:
Jonathan Rainville 2018-04-27 15:10:24 -04:00
parent 5aa05c8094
commit 94c493e854
3 changed files with 14 additions and 5 deletions

View File

@ -13,6 +13,7 @@
"any": "any"
},
"events": {
"contractFilesChanged": "contractFilesChanged"
"contractFilesChanged": "contractFilesChanged",
"contractConfigChanged": "contractConfigChanged"
}
}

View File

@ -19,8 +19,11 @@ class ContractsManager {
this.deployOnlyOnConfig = false;
this.events = options.events;
this.events.on(constants.events.contractFilesChanged, (newContracts) => {
this.contractFiles = newContracts;
this.events.on(constants.events.contractFilesChanged, (newContractFiles) => {
this.contractFiles = newContractFiles;
});
this.events.on(constants.events.contractConfigChanged, (newContracts) => {
this.contractsConfig = newContracts;
});
}

View File

@ -142,7 +142,12 @@ Config.prototype.loadContractsConfigFile = function() {
let configFilePath = this._getFileOrOject(this.configDir, 'contracts.json', 'contracts');
this.contractsConfig = this._mergeConfig(configFilePath, configObject, this.env);
const newContractsConfig = this._mergeConfig(configFilePath, configObject, this.env);
if (!deepEqual(newContractsConfig, this.contractsConfig)) {
this.events.emit(constants.events.contractConfigChanged, newContractsConfig);
this.contractsConfig = newContractsConfig;
}
};
Config.prototype.loadExternalContractsFiles = function() {
@ -220,7 +225,7 @@ Config.prototype.loadWebServerConfigFile = function() {
Config.prototype.loadEmbarkConfigFile = function() {
const contracts = this.embarkConfig.contracts;
const newContractsFiles = this.loadFiles(contracts);
if (newContractsFiles.length !== this.contractFiles || deepEqual(newContractsFiles, this.contractFiles)) {
if (!this.contractFiles || newContractsFiles.length !== this.contractFiles.length || !deepEqual(newContractsFiles, this.contractFiles)) {
this.events.emit(constants.events.contractFilesChanged, newContractsFiles);
this.contractsFiles = newContractsFiles;
}