Skip to content

Commit e63ca18

Browse files
authored
Merge pull request #529 from embark-framework/bug_fix/after-deploy
Fix afterDeploy in build and also build files
2 parents 15d9710 + cb8fd1c commit e63ca18

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

lib/contracts/deploy_manager.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,20 +133,22 @@ class DeployManager {
133133
return callback(new Error("error running afterDeploy"));
134134
}
135135

136-
// TODO: convert to for to avoid repeated callback
137-
for(let cmd of onDeployCode) {
136+
async.each(onDeployCode, (cmd, eachCb) => {
138137
self.logger.info("executing: " + cmd);
139138
try {
140139
RunCode.doEval(cmd, web3);
141140
} catch(e) {
142141
if (e.message.indexOf("invalid opcode") >= 0) {
143142
self.logger.error('the transaction was rejected; this usually happens due to a throw or a require, it can also happen due to an invalid operation');
144143
}
145-
return callback(new Error(e));
144+
return eachCb(new Error(e));
146145
}
147-
}
146+
eachCb();
147+
}, (err) => {
148+
callback(err, contractsManager);
149+
});
150+
148151

149-
callback(null, contractsManager);
150152
}
151153
], function (err, result) {
152154
if (err) {

lib/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,20 @@ class Embark {
202202
engine.deployManager.deployContracts(function (err) {
203203
callback(err);
204204
});
205+
},
206+
function waitForWriteFinish(callback) {
207+
engine.logger.info("Finished deploying".underline);
208+
// Necessary log for simple projects. This event is trigger to soon because there is no file
209+
// Also, not exiting straight after the deploy leaves time for async afterDeploys to finish
210+
engine.logger.info("If you have no files to build, you can exit now with CTRL+C");
211+
engine.events.on('outputDone', callback);
205212
}
206213
], function (err, _result) {
207214
if (err) {
208215
engine.logger.error(err.message);
209216
engine.logger.debug(err.stack);
210217
} else {
211-
engine.logger.info("finished building".underline);
218+
engine.logger.info("Finished building".underline);
212219
}
213220
// needed due to child processes
214221
process.exit();

0 commit comments

Comments
 (0)