diff --git a/docs/plugins.rst b/docs/plugins.rst index 9162bb64..49518ef0 100644 --- a/docs/plugins.rst +++ b/docs/plugins.rst @@ -158,7 +158,9 @@ example: module.exports = function(embark) { embark.registerBeforeDeploy(function(options) { - return options.contract.code.replace(/deaddeaddeaddeaddeaddeaddeaddeaddeaddead/ig, 'c0dec0dec0dec0dec0dec0dec0dec0dec0dec0de'); + var code = options.contract.code.replace(/deaddeaddeaddeaddeaddeaddeaddeaddeaddead/ig, 'c0dec0dec0dec0dec0dec0dec0dec0dec0dec0de'); + options.callback({ contractCode: code }); + return; // ignored }); } diff --git a/lib/contracts/deploy.js b/lib/contracts/deploy.js index 769a3824..27396a16 100644 --- a/lib/contracts/deploy.js +++ b/lib/contracts/deploy.js @@ -215,13 +215,13 @@ class Deploy { let beforeDeployPlugins = self.plugins.getPluginsFor('beforeDeploy'); async.waterfall([ - (asyncCallback)=>{ + (asyncCallback) => { //self.logger.info("applying beforeDeploy plugins...", beforeDeployPlugins.length); - async.eachSeries(beforeDeployPlugins, (plugin, eachPluginCb)=>{ + async.eachSeries(beforeDeployPlugins, (plugin, eachPluginCb) => { self.logger.info("running beforeDeploy plugin " + plugin.name + " ."); // calling each beforeDeploy handler declared by the plugin - async.eachSeries(plugin.beforeDeploy, (beforeDeployFn, eachCb)=>{ + async.eachSeries(plugin.beforeDeploy, (beforeDeployFn, eachCb) => { beforeDeployFn({ embarkDeploy: self, pluginConfig: plugin.pluginConfig, @@ -233,17 +233,17 @@ class Deploy { eachCb(); }) }); - }, ()=>{ + }, () => { //self.logger.info('All beforeDeploy handlers of the plugin has processed.'); eachPluginCb(); }); - }, ()=>{ + }, () => { //self.logger.info('All beforeDeploy plugins has been processed.'); contractCode = contract.code; asyncCallback(); }); }, - (asyncCallback)=>{ + (asyncCallback) => { let contractObject = new self.web3.eth.Contract(contract.abiDefinition); let deployObject; @@ -251,9 +251,13 @@ class Deploy { deployObject = contractObject.deploy({arguments: contractParams, data: "0x" + contractCode}); } catch(e) { if (e.indexOf('Invalid number of parameters for "undefined"') >= 0) { - return callback(new Error("attempted to deploy " + contractObject.className + " without specifying parameters")); + callback(new Error("attempted to deploy " + contractObject.className + " without specifying parameters")); + asyncCallback(); + return; } else { - return callback(new Error(e)); + callback(new Error(e)); + asyncCallback(); + return; } } @@ -285,6 +289,8 @@ class Deploy { }).on('error', function(error) { return callback(new Error("error deploying =" + contract.className + "= due to error: " + error.message)); }); + + asyncCallback(); } ]); // end of async.waterfall