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,20 +41,19 @@ class DeployManager {
|
|||
|
||||
deployAll(done) {
|
||||
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:list', (err, contracts) => {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
|
||||
self.logger.info(__("deploying contracts"));
|
||||
self.events.emit("deploy:beforeAll");
|
||||
self.events.request('contracts:dependencies', (err, contractDependencies) => {
|
||||
self.events.request('contracts:list', (err, contracts) => {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
|
||||
self.logger.info(__("deploying contracts"));
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
self.plugins.emitAndRunActionsForEvent("deploy:beforeAll", next);
|
||||
},
|
||||
function () {
|
||||
const contractDeploys = {};
|
||||
const errors = [];
|
||||
contracts.forEach(contract => {
|
||||
|
@ -100,10 +99,10 @@ class DeployManager {
|
|||
self.logger.error(e.message || e);
|
||||
done(__('Error deploying'));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
]);
|
||||
}
|
||||
]);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
deployContracts(done) {
|
||||
|
|
|
@ -19,7 +19,7 @@ class DeployTracker {
|
|||
registerEvents() {
|
||||
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) => {
|
||||
self.trackContract(contract.className, contract.realRuntimeBytecode, contract.realArgs, contract.deployedAddress);
|
||||
|
|
Loading…
Reference in New Issue