mirror of https://github.com/embarklabs/embark.git
Reduce coupling by using action for event
This commit is contained in:
parent
e20d7bfc6a
commit
1dfd2e980f
|
@ -41,11 +41,7 @@ class DeployManager {
|
||||||
|
|
||||||
deployAll(done) {
|
deployAll(done) {
|
||||||
let self = this;
|
let self = this;
|
||||||
async.waterfall([
|
|
||||||
function loadTracker(next) {
|
|
||||||
self.events.request("deployTracker:load", next);
|
|
||||||
},
|
|
||||||
function doDeployAll() {
|
|
||||||
self.events.request('contracts:dependencies', (err, contractDependencies) => {
|
self.events.request('contracts:dependencies', (err, contractDependencies) => {
|
||||||
self.events.request('contracts:list', (err, contracts) => {
|
self.events.request('contracts:list', (err, contracts) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -53,8 +49,11 @@ class DeployManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
self.logger.info(__("deploying contracts"));
|
self.logger.info(__("deploying contracts"));
|
||||||
self.events.emit("deploy:beforeAll");
|
async.waterfall([
|
||||||
|
function (next) {
|
||||||
|
self.plugins.emitAndRunActionsForEvent("deploy:beforeAll", next);
|
||||||
|
},
|
||||||
|
function () {
|
||||||
const contractDeploys = {};
|
const contractDeploys = {};
|
||||||
const errors = [];
|
const errors = [];
|
||||||
contracts.forEach(contract => {
|
contracts.forEach(contract => {
|
||||||
|
@ -100,10 +99,10 @@ class DeployManager {
|
||||||
self.logger.error(e.message || e);
|
self.logger.error(e.message || e);
|
||||||
done(__('Error deploying'));
|
done(__('Error deploying'));
|
||||||
}
|
}
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
deployContracts(done) {
|
deployContracts(done) {
|
||||||
|
|
|
@ -19,7 +19,7 @@ class DeployTracker {
|
||||||
registerEvents() {
|
registerEvents() {
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
this.events.setCommandHandler("deployTracker:load", this.setCurrentChain.bind(this));
|
this.embark.registerActionForEvent("deploy:beforeAll", this.setCurrentChain.bind(this));
|
||||||
|
|
||||||
this.events.on("deploy:contract:deployed", (contract) => {
|
this.events.on("deploy:contract:deployed", (contract) => {
|
||||||
self.trackContract(contract.className, contract.realRuntimeBytecode, contract.realArgs, contract.deployedAddress);
|
self.trackContract(contract.className, contract.realRuntimeBytecode, contract.realArgs, contract.deployedAddress);
|
||||||
|
|
Loading…
Reference in New Issue