mirror of
https://github.com/embarklabs/embark.git
synced 2025-01-11 14:24:24 +00:00
Merge pull request #530 from embark-framework/bug_fix/after-deploy-dev
Add file build to embark build and fix afterDeploy
This commit is contained in:
commit
9a261681da
@ -15,10 +15,16 @@ class CodeRunner {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.events.setCommandHandler('runcode:eval', (code, cb) => {
|
this.events.setCommandHandler('runcode:eval', (code, cb) => {
|
||||||
let result = RunCode.doEval(code);
|
if (!cb) {
|
||||||
if (cb) {
|
cb = function() {};
|
||||||
cb(null, result);
|
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
let result = RunCode.doEval(code);
|
||||||
|
cb(null, result);
|
||||||
|
} catch (e) {
|
||||||
|
cb(e);
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -203,6 +203,13 @@ class Embark {
|
|||||||
engine.events.request('deploy:contracts', function(err) {
|
engine.events.request('deploy:contracts', function(err) {
|
||||||
callback(err);
|
callback(err);
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
function waitForWriteFinish(callback) {
|
||||||
|
engine.logger.info("Finished deploying".underline);
|
||||||
|
// Necessary log for simple projects. This event is trigger to soon because there is no file
|
||||||
|
// Also, not exiting straight after the deploy leaves time for async afterDeploys to finish
|
||||||
|
engine.logger.info("If you have no files to build, you can exit now with CTRL+C");
|
||||||
|
engine.events.on('outputDone', callback);
|
||||||
}
|
}
|
||||||
], function (err, _result) {
|
], function (err, _result) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -52,30 +52,30 @@ class SpecialConfigs {
|
|||||||
|
|
||||||
async.mapLimit(afterDeployCmds, 1, (cmd, nextMapCb) => {
|
async.mapLimit(afterDeployCmds, 1, (cmd, nextMapCb) => {
|
||||||
self.replaceWithAddresses(cmd, nextMapCb);
|
self.replaceWithAddresses(cmd, nextMapCb);
|
||||||
}, (err, result) => {
|
}, (err, onDeployCode) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
self.logger.trace(err);
|
self.logger.trace(err);
|
||||||
return cb(new Error("error running afterDeploy"));
|
return cb(new Error("error running afterDeploy"));
|
||||||
}
|
}
|
||||||
let onDeployCode = result;
|
|
||||||
|
|
||||||
// TODO: convert to for to avoid repeated callback
|
self.runOnDeployCode(onDeployCode, cb);
|
||||||
for(let cmd of onDeployCode) {
|
|
||||||
self.logger.info("==== executing: " + cmd);
|
|
||||||
try {
|
|
||||||
self.events.request('runcode:eval', cmd);
|
|
||||||
} catch(e) {
|
|
||||||
if (e.message.indexOf("invalid opcode") >= 0) {
|
|
||||||
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');
|
|
||||||
}
|
|
||||||
return cb(new Error(e));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cb();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
runOnDeployCode(onDeployCode, callback) {
|
||||||
|
const self = this;
|
||||||
|
async.each(onDeployCode, (cmd, eachCb) => {
|
||||||
|
self.logger.info("==== executing: " + cmd);
|
||||||
|
self.events.request('runcode:eval', cmd, (err) => {
|
||||||
|
if (err && err.message.indexOf("invalid opcode") >= 0) {
|
||||||
|
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');
|
||||||
|
}
|
||||||
|
eachCb(err);
|
||||||
|
});
|
||||||
|
}, callback);
|
||||||
|
}
|
||||||
|
|
||||||
registerOnDeployAction() {
|
registerOnDeployAction() {
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
@ -92,25 +92,12 @@ class SpecialConfigs {
|
|||||||
|
|
||||||
async.mapLimit(onDeployCmds, 1, (cmd, nextMapCb) => {
|
async.mapLimit(onDeployCmds, 1, (cmd, nextMapCb) => {
|
||||||
self.replaceWithAddresses(cmd, nextMapCb);
|
self.replaceWithAddresses(cmd, nextMapCb);
|
||||||
}, (err, result) => {
|
}, (err, onDeployCode) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
return cb(new Error("error running onDeploy for " + contract.className.cyan));
|
return cb(new Error("error running onDeploy for " + contract.className.cyan));
|
||||||
}
|
}
|
||||||
let onDeployCode = result;
|
|
||||||
|
|
||||||
// TODO: convert to for to avoid repeated callback
|
self.runOnDeployCode(onDeployCode, cb);
|
||||||
for(let cmd of onDeployCode) {
|
|
||||||
self.logger.info("==== executing: " + cmd);
|
|
||||||
try {
|
|
||||||
self.events.request('runcode:eval', cmd);
|
|
||||||
} catch(e) {
|
|
||||||
if (e.message.indexOf("invalid opcode") >= 0) {
|
|
||||||
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');
|
|
||||||
}
|
|
||||||
return cb(new Error(e));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cb();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user