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