diff --git a/lib/modules/code_generator/index.js b/lib/modules/code_generator/index.js index ecc1aee5..371f6968 100644 --- a/lib/modules/code_generator/index.js +++ b/lib/modules/code_generator/index.js @@ -13,8 +13,7 @@ const Templates = { define_web3_simple: require('./code_templates/define-web3-simple.js.ejs'), web3_connector: require('./code_templates/web3-connector.js.ejs'), do_when_loaded: require('./code_templates/do-when-loaded.js.ejs'), - exec_when_env_loaded: require('./code_templates/exec-when-env-loaded.js.ejs'), - embark_building_placeholder: require('./code_templates/embark-building-placeholder.html.ejs') + exec_when_env_loaded: require('./code_templates/exec-when-env-loaded.js.ejs') }; class CodeGenerator { @@ -94,10 +93,6 @@ class CodeGenerator { cb(self.generateContractCode(contract, gasLimit)); }); - this.events.setCommandHandler('embark-building-placeholder', (cb) => { - self.buildPlaceholderPage(cb); - }); - self.events.setCommandHandler('code-generator:embarkjs:provider-code', (cb) => { cb(self.getEmbarkJsProviderCode()); }); @@ -379,12 +374,6 @@ class CodeGenerator { } ], cb); } - - buildPlaceholderPage(cb) { - let html = Templates.embark_building_placeholder({buildingMsg: __('Embark is building, please wait...')}); - cb(html); - } - } module.exports = CodeGenerator; diff --git a/lib/modules/webserver/index.js b/lib/modules/webserver/index.js index 3f335ea8..61c36eef 100644 --- a/lib/modules/webserver/index.js +++ b/lib/modules/webserver/index.js @@ -1,9 +1,14 @@ +const fs = require('../../core/fs.js'); var {canonicalHost} = require('../../utils/host.js'); var utils = require('../../utils/utils.js'); var Server = require('./server.js'); -class WebServer { +require('ejs'); +const Templates = { + embark_building_placeholder: require('./templates/embark-building-placeholder.html.ejs') +}; +class WebServer { constructor(embark, options) { this.embark = embark; this.logger = embark.logger; @@ -62,6 +67,7 @@ class WebServer { } listenToCommands() { + this.events.setCommandHandler('embark-building-placeholder', (cb) => this.buildPlaceholderPage(cb)); this.events.setCommandHandler('start-webserver', (callback) => this.server.start(callback)); this.events.setCommandHandler('stop-webserver', (callback) => this.server.stop(callback)); } @@ -82,6 +88,12 @@ class WebServer { }; }); } + + buildPlaceholderPage(cb) { + let html = Templates.embark_building_placeholder({buildingMsg: __('Embark is building, please wait...')}); + fs.mkdirpSync(this.buildDir); // create buildDir/ folder if not already exists + fs.writeFile(utils.joinPath(this.buildDir, 'index.html'), html, cb); + } } module.exports = WebServer; diff --git a/lib/modules/webserver/server.js b/lib/modules/webserver/server.js index 73ba07a7..7294bf03 100644 --- a/lib/modules/webserver/server.js +++ b/lib/modules/webserver/server.js @@ -1,15 +1,10 @@ let finalhandler = require('finalhandler'); -const fs = require('../../core/fs.js'); let http = require('http'); let serveStatic = require('serve-static'); const {canonicalHost, defaultHost, dockerHostSwap} = require('../../utils/host'); const opn = require('opn'); -const utils = require('../../utils/utils.js'); require('http-shutdown').extend(); -require('ejs'); -const embark_building_placeholder = require('../code_generator/code_templates/embark-building-placeholder.html.ejs'); - class Server { constructor(options) { this.buildDir = options.buildDir; @@ -32,12 +27,6 @@ class Server { serve(req, res, finalhandler(req, res)); }).withShutdown(); - if (this.isFirstStart) { - const html = embark_building_placeholder({buildingMsg: __('Embark is building, please wait...')}); - fs.mkdirpSync(this.dist); // create dist/ folder if not already exists - fs.writeFileSync(utils.joinPath(this.dist, 'index.html'), html); - this.isFirstStart = false; - } this.server.listen(this.port, this.hostname, () => { this.port = this.server.address().port; diff --git a/lib/modules/code_generator/code_templates/embark-building-placeholder.html.ejs b/lib/modules/webserver/templates/embark-building-placeholder.html.ejs similarity index 100% rename from lib/modules/code_generator/code_templates/embark-building-placeholder.html.ejs rename to lib/modules/webserver/templates/embark-building-placeholder.html.ejs diff --git a/lib/pipeline/pipeline.js b/lib/pipeline/pipeline.js index 1f0a742b..7d2b7538 100644 --- a/lib/pipeline/pipeline.js +++ b/lib/pipeline/pipeline.js @@ -29,10 +29,6 @@ class Pipeline { async.waterfall([ function createPlaceholderPage(next){ - self.events.request('embark-building-placeholder', (html) => { - fs.mkdirpSync(self.buildDir); // create dist/ folder if not already exists - fs.writeFile(utils.joinPath(self.buildDir, 'index.html'), html, next); - }); }, function buildTheContracts(next) { self.buildContracts(next);