fix watch by not restarting anymore and enable config for contracts

This commit is contained in:
Jonathan Rainville 2018-06-14 09:15:31 -04:00
parent 977b472217
commit 37b69b43ff
2 changed files with 7 additions and 7 deletions

View File

@ -108,9 +108,6 @@ class Engine {
this.events.on('code-generator-ready', function () { this.events.on('code-generator-ready', function () {
self.events.request('code', function (abi, contractsJSON) { self.events.request('code', function (abi, contractsJSON) {
pipeline.build(abi, contractsJSON, null, () => { pipeline.build(abi, contractsJSON, null, () => {
if (self.watch) {
self.watch.restart(); // Necessary because changing a file while it is writing can stop it from being watched
}
self.events.emit('outputDone'); self.events.emit('outputDone');
}); });
}); });

View File

@ -27,7 +27,7 @@ class Watch {
self.logger.trace('ready to watch contract changes'); self.logger.trace('ready to watch contract changes');
}); });
this.watchConfigs(function () { this.watchConfigs(embarkConfig, function () {
self.logger.trace('ready to watch config changes'); self.logger.trace('ready to watch config changes');
}); });
@ -45,7 +45,6 @@ class Watch {
if (fileWatcher.isReady) fileWatcher.close(); if (fileWatcher.isReady) fileWatcher.close();
fileWatcher.shouldClose = true; fileWatcher.shouldClose = true;
}); });
this.fileWatchers = [];
} }
watchAssets(embarkConfig, callback) { watchAssets(embarkConfig, callback) {
@ -98,10 +97,14 @@ class Watch {
); );
} }
watchConfigs(callback) { watchConfigs(embarkConfig, callback) {
let self = this; let self = this;
let configFolder = embarkConfig.config.replace(/\\/g, '/');
if (configFolder.charAt(configFolder.length - 1) !== '/') {
configFolder += '/';
}
this.watchFiles( this.watchFiles(
"config/**/contracts.json", [`${configFolder}**/contracts.json`, `${configFolder}**/contracts.js`],
function (eventName, path) { function (eventName, path) {
self.logger.info(`${eventName}: ${path}`); self.logger.info(`${eventName}: ${path}`);
self.events.emit('file-' + eventName, 'config', path); self.events.emit('file-' + eventName, 'config', path);