Skip to content

Commit 94c493e

Browse files
committed
redeploy with right config on config change
1 parent 5aa05c8 commit 94c493e

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

lib/constants.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"any": "any"
1414
},
1515
"events": {
16-
"contractFilesChanged": "contractFilesChanged"
16+
"contractFilesChanged": "contractFilesChanged",
17+
"contractConfigChanged": "contractConfigChanged"
1718
}
1819
}

lib/contracts/contracts.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@ class ContractsManager {
1919
this.deployOnlyOnConfig = false;
2020
this.events = options.events;
2121

22-
this.events.on(constants.events.contractFilesChanged, (newContracts) => {
23-
this.contractFiles = newContracts;
22+
this.events.on(constants.events.contractFilesChanged, (newContractFiles) => {
23+
this.contractFiles = newContractFiles;
24+
});
25+
this.events.on(constants.events.contractConfigChanged, (newContracts) => {
26+
this.contractsConfig = newContracts;
2427
});
2528
}
2629

lib/core/config.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,12 @@ Config.prototype.loadContractsConfigFile = function() {
142142

143143
let configFilePath = this._getFileOrOject(this.configDir, 'contracts.json', 'contracts');
144144

145-
this.contractsConfig = this._mergeConfig(configFilePath, configObject, this.env);
145+
const newContractsConfig = this._mergeConfig(configFilePath, configObject, this.env);
146+
147+
if (!deepEqual(newContractsConfig, this.contractsConfig)) {
148+
this.events.emit(constants.events.contractConfigChanged, newContractsConfig);
149+
this.contractsConfig = newContractsConfig;
150+
}
146151
};
147152

148153
Config.prototype.loadExternalContractsFiles = function() {
@@ -220,7 +225,7 @@ Config.prototype.loadWebServerConfigFile = function() {
220225
Config.prototype.loadEmbarkConfigFile = function() {
221226
const contracts = this.embarkConfig.contracts;
222227
const newContractsFiles = this.loadFiles(contracts);
223-
if (newContractsFiles.length !== this.contractFiles || deepEqual(newContractsFiles, this.contractFiles)) {
228+
if (!this.contractFiles || newContractsFiles.length !== this.contractFiles.length || !deepEqual(newContractsFiles, this.contractFiles)) {
224229
this.events.emit(constants.events.contractFilesChanged, newContractsFiles);
225230
this.contractsFiles = newContractsFiles;
226231
}

0 commit comments

Comments
 (0)