mirror of https://github.com/embarklabs/embark.git
fix errors handling so it doesn't attempt to continue building when there are fatal errors compiling contracts
This commit is contained in:
parent
dd4088fd08
commit
c8b52a1746
|
@ -43,7 +43,7 @@ class CodeGenerator {
|
|||
|
||||
// new events
|
||||
this.events.setCommandHandler('code-vanila', function(cb) {
|
||||
self.events.request("contracts:list", (contractsList) => {
|
||||
self.events.request("contracts:list", (_err, contractsList) => {
|
||||
let vanillaABI = self.generateABI(contractsList, {useEmbarkJS: false});
|
||||
let contractsJSON = self.generateContractsJSON(contractsList);
|
||||
cb(vanillaABI, contractsJSON);
|
||||
|
@ -51,7 +51,7 @@ class CodeGenerator {
|
|||
});
|
||||
|
||||
this.events.setCommandHandler('code', function(cb) {
|
||||
self.events.request("contracts:list", (contractsList) => {
|
||||
self.events.request("contracts:list", (_err, contractsList) => {
|
||||
let embarkJSABI = self.generateABI(contractsList, {useEmbarkJS: true});
|
||||
let contractsJSON = self.generateContractsJSON(contractsList);
|
||||
cb(embarkJSABI, contractsJSON);
|
||||
|
@ -59,7 +59,7 @@ class CodeGenerator {
|
|||
});
|
||||
|
||||
this.events.setCommandHandler('code-contracts-vanila', function(cb) {
|
||||
self.events.request("contracts:list", (contractsList) => {
|
||||
self.events.request("contracts:list", (_err, contractsList) => {
|
||||
let vanillaContractsABI = self.generateContracts(contractsList, false, true, false);
|
||||
let contractsJSON = self.generateContractsJSON(contractsList);
|
||||
cb(vanillaContractsABI, contractsJSON);
|
||||
|
@ -67,7 +67,7 @@ class CodeGenerator {
|
|||
});
|
||||
|
||||
this.events.setCommandHandler('code-vanila-deployment', function(cb) {
|
||||
self.events.request("contracts:list", (contractsList) => {
|
||||
self.events.request("contracts:list", (_err, contractsList) => {
|
||||
let vanillaABI = self.generateABI(contractsList, {useEmbarkJS: false, deployment: true});
|
||||
let contractsJSON = self.generateContractsJSON(contractsList);
|
||||
cb(vanillaABI, contractsJSON);
|
||||
|
|
|
@ -170,7 +170,7 @@ class ContractDeployer {
|
|||
});
|
||||
},
|
||||
function doLinking(next) {
|
||||
self.events.request('contracts:list', (contracts) => {
|
||||
self.events.request('contracts:list', (_err, contracts) => {
|
||||
for (let contractObj of contracts) {
|
||||
let filename = contractObj.filename;
|
||||
let deployedAddress = contractObj.deployedAddress;
|
||||
|
|
|
@ -18,6 +18,7 @@ class ContractsManager {
|
|||
this.gasLimit = options.gasLimit;
|
||||
this.deployOnlyOnConfig = false;
|
||||
this.events = options.events;
|
||||
this.compileError = false;
|
||||
|
||||
self.events.on(constants.events.contractFilesChanged, (newContractFiles) => {
|
||||
self.contractFiles = newContractFiles;
|
||||
|
@ -27,7 +28,7 @@ class ContractsManager {
|
|||
});
|
||||
|
||||
self.events.setCommandHandler('contracts:list', (cb) => {
|
||||
cb(self.listContracts());
|
||||
cb(self.compileError, self.listContracts());
|
||||
});
|
||||
|
||||
self.events.setCommandHandler("contracts:contract", (contractName, cb) => {
|
||||
|
@ -36,8 +37,8 @@ class ContractsManager {
|
|||
|
||||
self.events.setCommandHandler("contracts:build", (configOnly, cb) => {
|
||||
self.deployOnlyOnConfig = configOnly; // temporary, should refactor
|
||||
self.build(() => {
|
||||
cb();
|
||||
self.build((err) => {
|
||||
cb(err);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -59,6 +60,7 @@ class ContractsManager {
|
|||
let self = this;
|
||||
async.waterfall([
|
||||
function compileContracts(callback) {
|
||||
self.events.emit("status", __("Compiling..."));
|
||||
if (process.env.isTest && self.compiledContracts && Object.keys(self.compiledContracts).length) {
|
||||
// Only compile once for tests
|
||||
return callback();
|
||||
|
@ -69,6 +71,7 @@ class ContractsManager {
|
|||
});
|
||||
},
|
||||
function prepareContractsFromConfig(callback) {
|
||||
self.events.emit("status", __("Building..."));
|
||||
let className, contract;
|
||||
for (className in self.contractsConfig.contracts) {
|
||||
contract = self.contractsConfig.contracts[className];
|
||||
|
@ -247,6 +250,8 @@ class ContractsManager {
|
|||
}
|
||||
], function (err, _result) {
|
||||
if (err) {
|
||||
self.compileError = true;
|
||||
self.events.emit("status", __("Compile/Build error"));
|
||||
self.logger.error(__("Error Compiling/Building contracts: ") + err);
|
||||
}
|
||||
self.logger.trace("finished".underline);
|
||||
|
|
|
@ -22,10 +22,15 @@ class DeployManager {
|
|||
|
||||
deployAll(done) {
|
||||
let self = this;
|
||||
this.logger.info(__("deploying contracts"));
|
||||
this.events.emit("deploy:beforeAll");
|
||||
|
||||
self.events.request('contracts:list', (contracts) => {
|
||||
self.events.request('contracts:list', (err, contracts) => {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
|
||||
self.logger.info(__("deploying contracts"));
|
||||
self.events.emit("deploy:beforeAll");
|
||||
|
||||
async.eachOfSeries(contracts,
|
||||
function (contract, key, callback) {
|
||||
contract._gasLimit = self.gasLimit;
|
||||
|
@ -61,8 +66,8 @@ class DeployManager {
|
|||
|
||||
async.waterfall([
|
||||
function buildContracts(callback) {
|
||||
self.events.request("contracts:build", self.deployOnlyOnConfig, () => {
|
||||
callback();
|
||||
self.events.request("contracts:build", self.deployOnlyOnConfig, (err) => {
|
||||
callback(err);
|
||||
});
|
||||
},
|
||||
|
||||
|
|
|
@ -125,7 +125,10 @@ class Embark {
|
|||
engine.events.on('check:backOnline:Ethereum', function () {
|
||||
engine.logger.info(__('Ethereum node detected') + '..');
|
||||
engine.config.reloadConfig();
|
||||
engine.events.request('deploy:contracts', function() {
|
||||
engine.events.request('deploy:contracts', function(err) {
|
||||
if (err) {
|
||||
return;
|
||||
}
|
||||
engine.logger.info(__('Deployment Done'));
|
||||
});
|
||||
});
|
||||
|
|
|
@ -53,7 +53,7 @@ class Pipeline {
|
|||
next();
|
||||
},
|
||||
function writeContracts(next) {
|
||||
self.events.request('contracts:list', (contracts) => {
|
||||
self.events.request('contracts:list', (_err, contracts) => {
|
||||
// ensure the .embark/contracts directory exists (create if not exists)
|
||||
fs.mkdirp(fs.dappPath(".embark/contracts", ''), (err) => {
|
||||
if(err) return next(err);
|
||||
|
@ -224,8 +224,8 @@ class Pipeline {
|
|||
});
|
||||
},
|
||||
function getContracts(next) {
|
||||
self.events.request('contracts:list', (contracts) => {
|
||||
next(null, contracts);
|
||||
self.events.request('contracts:list', (err, contracts) => {
|
||||
next(err, contracts);
|
||||
});
|
||||
},
|
||||
function writeContractsJSON(contracts, next) {
|
||||
|
|
Loading…
Reference in New Issue