fix(commands/build): don't start blockchain node when `--contracts` is used

Prior to this commit `$ embark build --contracts` spinned up a blockchain node
which is not necessary as `--contracts` can be seen as a "compile only" option.

This commit ensures we don't start any web3 services with `--contracts` is used.
This commit is contained in:
Pascal Precht 2018-10-09 15:12:33 +02:00
parent e48de3d2ea
commit 80c80e9beb
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D
2 changed files with 21 additions and 13 deletions

View File

@ -205,22 +205,25 @@ class EmbarkController {
engine.startService("processManager");
engine.startService("libraryManager");
engine.startService("codeRunner");
engine.startService("web3");
if (!options.onlyCompile) {
engine.startService("web3");
engine.startService("deployment", {onlyCompile: options.onlyCompile});
engine.startService("pipeline");
}
engine.startService("deployment", {onlyCompile: options.onlyCompile});
if (!options.onlyCompile) {
engine.startService("storage");
engine.startService("codeGenerator");
} else {
engine.startService('compiler');
}
callback();
},
function deploy(callback) {
engine.events.request('deploy:contracts', function (err) {
callback(err);
});
function buildOrBuildAndDeploy(callback) {
if (options.onlyCompile) {
engine.events.request('contracts:build', {}, err => callback(err));
} else {
// deploy:contracts will trigger a build as well
engine.events.request('deploy:contracts', err => callback(err));
}
},
function waitForWriteFinish(callback) {
if (options.onlyCompile) {
@ -229,7 +232,7 @@ class EmbarkController {
}
engine.logger.info("Finished deploying".underline);
engine.events.on('outputDone', (err) => {
engine.logger.info(__("finished building").underline);
engine.logger.info(__("Finished building").underline);
callback(err, true);
});
}

View File

@ -63,6 +63,7 @@ class Engine {
"pipeline": this.pipelineService,
"codeRunner": this.codeRunnerService,
"codeGenerator": this.codeGeneratorService,
"compiler": this.setupCompilerAndContractsManagerService,
"deployment": this.deploymentService,
"fileWatcher": this.fileWatchService,
"webServer": this.webServerService,
@ -178,17 +179,21 @@ class Engine {
this.events.on('asset-changed', addToCargo);
}
setupCompilerAndContractsManagerService(options) {
this.registerModule('compiler', {plugins: this.plugins, disableOptimizations: options.disableOptimizations});
this.registerModule('solidity', {ipc: this.ipc, useDashboard: this.useDashboard});
this.registerModule('vyper');
this.registerModule('contracts_manager', {compileOnceOnly: options.compileOnceOnly});
}
deploymentService(options) {
let self = this;
this.registerModule('compiler', {plugins: self.plugins, disableOptimizations: options.disableOptimizations});
this.registerModule('solidity', {ipc: self.ipc, useDashboard: this.useDashboard});
this.registerModule('vyper');
this.setupCompilerAndContractsManagerService(options);
this.registerModule('profiler');
this.registerModule('deploytracker', {trackContracts: options.trackContracts});
this.registerModule('specialconfigs');
this.registerModule('console_listener', {ipc: self.ipc});
this.registerModule('contracts_manager', {compileOnceOnly: options.compileOnceOnly});
this.registerModule('deployment', {plugins: this.plugins, onlyCompile: options.onlyCompile});
this.events.on('file-event', function (fileType) {