diff --git a/lib/contracts/deploy.js b/lib/contracts/deploy.js index 25b95c9e5..20aac7d38 100644 --- a/lib/contracts/deploy.js +++ b/lib/contracts/deploy.js @@ -186,34 +186,7 @@ class Deploy { }); }, function applyBeforeDeploy(next) { - let beforeDeployPlugins = self.plugins.getPluginsFor('beforeDeploy'); - - //self.logger.info("applying beforeDeploy plugins...", beforeDeployPlugins.length); - async.eachSeries(beforeDeployPlugins, (plugin, eachPluginCb) => { - self.logger.info(__("running beforeDeploy plugin %s .", plugin.name)); - - // calling each beforeDeploy handler declared by the plugin - async.eachSeries(plugin.beforeDeploy, (beforeDeployFn, eachCb) => { - function beforeDeployCb(resObj){ - contract.code = resObj.contractCode; - eachCb(); - } - beforeDeployFn({ - embarkDeploy: self, - pluginConfig: plugin.pluginConfig, - deploymentAccount: deploymentAccount, - contract: contract, - callback: beforeDeployCb - }, beforeDeployCb); - }, () => { - //self.logger.info('All beforeDeploy handlers of the plugin has processed.'); - eachPluginCb(); - }); - }, () => { - //self.logger.info('All beforeDeploy plugins has been processed.'); - contractCode = contract.code; - next(); - }); + self.plugins.runActionsForEvent('deploy:contract:beforeDeploy', {contract: contract}, next); }, function createDeployObject(next) { let contractObject = self.blockchain.ContractObject({abi: contract.abiDefinition}); diff --git a/test_apps/test_app/extensions/embark-service/index.js b/test_apps/test_app/extensions/embark-service/index.js index 6783352a0..7717c7602 100644 --- a/test_apps/test_app/extensions/embark-service/index.js +++ b/test_apps/test_app/extensions/embark-service/index.js @@ -23,9 +23,12 @@ module.exports = function (embark) { embark.addFileToPipeline('./fileInPipeline.js'); embark.addFileToPipeline('./fileInPipeline.js', 'js/fileInPipeline.js'); - embark.registerBeforeDeploy(function (options, callback) { - // Just calling register to prove it works. We don't actually want to change the contracts - callback({contractCode: options.contract.code}); + embark.registerActionForEvent("deploy:contract:beforeDeploy", (params, cb) => { + embark.logger.info("applying beforeDeploy plugin..."); + //console.dir(params); + //console.dir(cb); + //console.dir('------------------'); + cb(); }); // NOTE: uncommenting this will make dappConnection stop working