Merge branch 'refactor_5_0_0' of github.com:embark-framework/embark into refactor_5_0_0

This commit is contained in:
Iuri Matias 2019-08-19 17:48:52 -04:00
commit 9b5ced01dd
2 changed files with 22 additions and 16 deletions

View File

@ -58,6 +58,7 @@ export default class TrackingFunctions {
} }
setCurrentChain(_params, callback) { setCurrentChain(_params, callback) {
if (!this.chainFile) return callback();
if (this.chainFile === false) return callback(); if (this.chainFile === false) return callback();
if (this.chainConfig === false) { if (this.chainConfig === false) {
this.currentChain = {contracts: []}; this.currentChain = {contracts: []};

View File

@ -15,8 +15,7 @@ class Deployment {
this.contractDeployer = new ContractDeployer({ this.contractDeployer = new ContractDeployer({
events: this.events, events: this.events,
plugins: this.plugins, plugins: this.plugins
logger: this.logger
}); });
this.events.setCommandHandler('deployment:contracts:deploy', (contractsList, contractDependencies, cb) => { this.events.setCommandHandler('deployment:contracts:deploy', (contractsList, contractDependencies, cb) => {
@ -28,17 +27,23 @@ class Deployment {
this.logger.info(__("deploying contracts")); this.logger.info(__("deploying contracts"));
async.waterfall([ async.waterfall([
// TODO used to be called this.plugins.emitAndRunActionsForEvent("deploy:beforeAll", (err) => { // TODO used to be called this.plugins.emitAndRunActionsForEvent("deploy:beforeAll", (err) => {
(next) => {this.plugins.emitAndRunActionsForEvent('deployment:deployContracts:beforeAll', {}, () => {next()});},
(next) => {this.deployAll(contracts, contractDependencies, next);},
(next) => { (next) => {
this.events.emit('contractsDeployed'); this.plugins.emitAndRunActionsForEvent('deployment:deployContracts:beforeAll', {}, (err) => {
this.plugins.emitAndRunActionsForEvent('deployment:deployContracts:afterAll', {}, () => {next()}); next(err);
console.dir("==== finished deploying"); });
},
(next) => {this.deployAll(contracts, contractDependencies, next);},
], (err) => {
if (err) {
this.events.emit("outputError", err.message || err);
this.logger.error(err.message || err);
} }
], done); this.events.emit('contractsDeployed');
this.plugins.emitAndRunActionsForEvent('deployment:deployContracts:afterAll', {}, done);
});
} }
deployContract(contract, errors, callback) { deployContract(contract, callback) {
console.dir("requesting to deploy contract") console.dir("requesting to deploy contract")
this.events.request('deployment:contract:deploy', contract, (err) => { this.events.request('deployment:contract:deploy', contract, (err) => {
if (err) { if (err) {
@ -48,7 +53,7 @@ class Deployment {
} else { } else {
this.logger.error(`[${contract.className}]: ${err.message || err}`); this.logger.error(`[${contract.className}]: ${err.message || err}`);
} }
errors.push(err); return callback(err);
} }
callback(); callback();
}); });
@ -64,7 +69,12 @@ class Deployment {
function deploy(result, callback) { function deploy(result, callback) {
console.dir("== deploy") console.dir("== deploy")
if (typeof result === 'function') callback = result; if (typeof result === 'function') callback = result;
self.deployContract(contract, errors, callback); self.deployContract(contract, (err) => {
if (err) {
errors.push(err);
}
callback();
});
} }
const className = contract.className; const className = contract.className;
@ -77,13 +87,8 @@ class Deployment {
}) })
async.auto(contractDeploys, (err, _results) => { async.auto(contractDeploys, (err, _results) => {
if (err) {
console.dir("error deploying contracts")
console.dir(err)
}
if (errors.length) { if (errors.length) {
err = __("Error deploying contracts. Please fix errors to continue."); err = __("Error deploying contracts. Please fix errors to continue.");
this.events.emit("outputError", __("Error deploying contracts, please check console"));
return done(err); return done(err);
} }
if (contracts.length === 0) { if (contracts.length === 0) {