diff --git a/lib/index.js b/lib/index.js index dddc6554..1062eb69 100644 --- a/lib/index.js +++ b/lib/index.js @@ -53,33 +53,7 @@ var Embark = { self.config.reloadConfig(); callback(); }, - function deployAndBuildContractsManager(callback) { - Embark.monitor.setStatus("Redeploying changed Contracts"); - Embark.buildAndDeploy(function(contractsManager) { - callback(null, contractsManager); - }); - }, - function generateConsoleABI(contractsManager, callback) { - var abiGenerator = new ABIGenerator(self.config.blockchainConfig, contractsManager); - var consoleABI = abiGenerator.generateABI({useEmbarkJS: false}); - Embark.console.runCode(consoleABI); - callback(null, contractsManager); - }, - function generateABI(contractsManager, callback) { - var abiGenerator = new ABIGenerator(self.config.blockchainConfig, contractsManager); - callback(null, abiGenerator.generateABI({useEmbarkJS: true})); - }, - function buildPipeline(abi, callback) { - Embark.monitor.setStatus("Building Assets"); - var pipeline = new Pipeline({ - buildDir: self.config.buildDir, - contractsFiles: self.config.contractsFiles, - assetFiles: self.config.assetFiles, - logger: self.logger - }); - pipeline.build(abi); - callback(); - } + self.buildDeployGenerate.bind(self) ], function(err, result) { Embark.monitor.setStatus("Ready"); self.logger.trace("finished".underline); @@ -112,33 +86,7 @@ var Embark = { Embark.servicesMonitor.startMonitor(); callback(); }, - function deployAndBuildContractsManager(callback) { - Embark.monitor.setStatus("Deploying Contracts"); - Embark.buildAndDeploy(function(contractsManager) { - callback(null, contractsManager); - }); - }, - function generateConsoleABI(contractsManager, callback) { - var abiGenerator = new ABIGenerator(self.config.blockchainConfig, contractsManager); - var consoleABI = abiGenerator.generateABI({useEmbarkJS: false}); - Embark.console.runCode(consoleABI); - callback(null, contractsManager); - }, - function generateABI(contractsManager, callback) { - var abiGenerator = new ABIGenerator(self.config.blockchainConfig, contractsManager); - callback(null, abiGenerator.generateABI({useEmbarkJS: true})); - }, - function buildPipeline(abi, callback) { - Embark.monitor.setStatus("Building Assets"); - var pipeline = new Pipeline({ - buildDir: self.config.buildDir, - contractsFiles: self.config.contractsFiles, - assetFiles: self.config.assetFiles, - logger: self.logger - }); - pipeline.build(abi); - callback(); - }, + self.buildDeployGenerate.bind(self), function startAssetServer(callback) { Embark.monitor.setStatus("Starting Server"); var server = new Server({logger: self.logger, port: options.serverPort}); @@ -252,6 +200,43 @@ var Embark = { }); }, + + buildDeployGenerate: function(done) { + var self = this; + + async.waterfall([ + function deployAndBuildContractsManager(callback) { + Embark.monitor.setStatus("Deploying Contracts"); + Embark.buildAndDeploy(function(contractsManager) { + callback(null, contractsManager); + }); + }, + function generateConsoleABI(contractsManager, callback) { + var abiGenerator = new ABIGenerator(self.config.blockchainConfig, contractsManager); + var consoleABI = abiGenerator.generateABI({useEmbarkJS: false}); + Embark.console.runCode(consoleABI); + callback(null, contractsManager); + }, + function generateABI(contractsManager, callback) { + var abiGenerator = new ABIGenerator(self.config.blockchainConfig, contractsManager); + callback(null, abiGenerator.generateABI({useEmbarkJS: true})); + }, + function buildPipeline(abi, callback) { + Embark.monitor.setStatus("Building Assets"); + var pipeline = new Pipeline({ + buildDir: self.config.buildDir, + contractsFiles: self.config.contractsFiles, + assetFiles: self.config.assetFiles, + logger: self.logger + }); + pipeline.build(abi); + callback(); + } + ], function(err, result) { + done(result); + }); + }, + initTests: function(options) { return new Test(options); },