diff --git a/cmd/cmd_controller.js b/cmd/cmd_controller.js index 03c67926..c291c03a 100644 --- a/cmd/cmd_controller.js +++ b/cmd/cmd_controller.js @@ -465,13 +465,14 @@ class EmbarkController { engine.startService("scaffolding"); callback(); }, - function generateContract(callback){ - engine.events.request('scaffolding:generate:contract', options, function(){ - // Engine is re-initiated to be able to see the new contract file - engine.init({}, callback); + function generateContract(callback) { + engine.events.request('scaffolding:generate:contract', options, function(err, file) { + // Add contract file to the manager + engine.events.request('config:contractsFiles:add', file); + callback(); }); }, - function initEngineServices(callback){ + function initEngineServices(callback) { let pluginList = engine.plugins.listPlugins(); if (pluginList.length > 0) { engine.logger.info(__("loaded plugins") + ": " + pluginList.join(", ")); @@ -481,15 +482,15 @@ class EmbarkController { engine.startService("codeRunner"); engine.startService("web3"); engine.startService("deployment", {onlyCompile: true}); - + callback(); }, function deploy(callback) { - engine.events.request('deploy:contracts', function (err) { + engine.events.request('deploy:contracts', function(err) { callback(err); }); }, - function generateUI(callback){ + function generateUI(callback) { engine.events.request("scaffolding:generate:ui", options, () => { callback(); }); @@ -502,7 +503,7 @@ class EmbarkController { ` ],\n` + ` "index.html": "app/${options.contract}.html"`).cyan); process.exit(); - }); + }); } upload(options) { diff --git a/lib/modules/scaffolding-react/index.js b/lib/modules/scaffolding-react/index.js index 8767cc52..cec04e1b 100644 --- a/lib/modules/scaffolding-react/index.js +++ b/lib/modules/scaffolding-react/index.js @@ -75,6 +75,7 @@ class ScaffoldingReact { // Write template const result = template(data); fs.writeFileSync(filePath, result); + return filePath; } build(contract, overwrite, cb) { @@ -94,7 +95,7 @@ class ScaffoldingReact { filename }, overwrite); - this._generateFile(contract, 'dapp.js.tpl', 'js', + const filePath = this._generateFile(contract, 'dapp.js.tpl', 'js', { 'title': contract.className, 'contractName': contract.className, @@ -112,11 +113,11 @@ class ScaffoldingReact { this.embark.logger.info('app/' + filename + ".html generated"); this.embark.logger.info('app/' + filename + ".js generated"); + cb(null, filePath); } catch (error) { this.embark.logger.error(error.message); process.exit(1); } - cb(); }); } } diff --git a/lib/modules/scaffolding-solidity/index.js b/lib/modules/scaffolding-solidity/index.js index c1d59d09..0a05b71a 100644 --- a/lib/modules/scaffolding-solidity/index.js +++ b/lib/modules/scaffolding-solidity/index.js @@ -25,6 +25,7 @@ class ScaffoldingSolidity { // Write template const result = template(data); fs.writeFileSync(filePath, result); + return filePath; } build(contract, overwrite, cb){ @@ -33,7 +34,7 @@ class ScaffoldingSolidity { const filename = contract.className; - this._generateFile(contract, 'contract.sol.tpl', 'sol', { + const filePath = this._generateFile(contract, 'contract.sol.tpl', 'sol', { 'contractName': contract.className, 'structName': contract.className + "Struct", 'fields': Object.keys(contract.fields).map(f => { @@ -42,7 +43,7 @@ class ScaffoldingSolidity { }, overwrite); this.embark.logger.info("contracts/" + filename + ".sol generated"); - cb(); + cb(null, filePath); } catch(error) { this.embark.logger.error(error.message); process.exit(1);