diff --git a/lib/contracts/code_generator.js b/lib/contracts/code_generator.js index 23948dab..703f2c91 100644 --- a/lib/contracts/code_generator.js +++ b/lib/contracts/code_generator.js @@ -353,15 +353,7 @@ class CodeGenerator { code += "\nglobal.__embarkContext = __mainContext.__loadManagerInstance;\n"; code += "\nwindow.web3 = web3;\n"; code += "\nexport default web3;\n"; - next(); - }, - function makeDirectory(next) { - fs.mkdirp(fs.dappPath(".embark"), (err, _result) => { - next(err); - }); - }, - function writeFile(next) { - fs.writeFile(fs.dappPath(".embark", 'web3_instance.js'), code, next); + next(null, code); } ], cb); } diff --git a/lib/pipeline/pipeline.js b/lib/pipeline/pipeline.js index 98be95b1..2cb2c79e 100644 --- a/lib/pipeline/pipeline.js +++ b/lib/pipeline/pipeline.js @@ -31,7 +31,7 @@ class Pipeline { self.buildContracts(contractsJSON, next); }, function buildWeb3(next) { - self.events.request('code-generator:web3js', next); + self.buildWeb3JS(next); }, function createImportList(next) { importsList["Embark/EmbarkJS"] = fs.dappPath(".embark", 'embark.js'); @@ -211,6 +211,23 @@ class Pipeline { }); } + buildWeb3JS(cb) { + const self = this; + async.waterfall([ + function getWeb3Code(next) { + self.events.request('code-generator:web3js', next); + }, + function makeDirectory(code, next) { + fs.mkdirp(fs.dappPath(".embark"), (err, _result) => { + next(err, code); + }); + }, + function writeFile(code, next) { + fs.writeFile(fs.dappPath(".embark", 'web3_instance.js'), code, next); + } + ], cb); + } + } module.exports = Pipeline;