diff --git a/lib/core/fs.js b/lib/core/fs.js index 84fb6bdf..6dbc1228 100644 --- a/lib/core/fs.js +++ b/lib/core/fs.js @@ -19,6 +19,10 @@ function copySync() { return fs.copySync.apply(fs.copySync, arguments); } +function move(){ + return fs.move.apply(fs.move, arguments); +} + function appendFileSync() { return fs.appendFileSync.apply(fs.writeFileSync, arguments); } @@ -87,6 +91,7 @@ module.exports = { mkdirp, copy, copySync, + move, readFile, readFileSync, appendFileSync, diff --git a/lib/i18n/locales/en.json b/lib/i18n/locales/en.json index 81f2aa87..458d22bd 100644 --- a/lib/i18n/locales/en.json +++ b/lib/i18n/locales/en.json @@ -104,5 +104,6 @@ "Ethereum node (version unknown)": "Ethereum node (version unknown)", "No Blockchain node found": "No Blockchain node found", "Couldn't connect to an Ethereum node are you sure it's on?": "Couldn't connect to an Ethereum node are you sure it's on?", - "make sure you have an Ethereum node or simulator running. e.g '%s'": "make sure you have an Ethereum node or simulator running. e.g '%s'" + "make sure you have an Ethereum node or simulator running. e.g '%s'": "make sure you have an Ethereum node or simulator running. e.g '%s'", + "Embark is building, please wait...": "Embark is building, please wait..." } \ No newline at end of file diff --git a/lib/pipeline/pipeline.js b/lib/pipeline/pipeline.js index 5bcea392..4f74a669 100644 --- a/lib/pipeline/pipeline.js +++ b/lib/pipeline/pipeline.js @@ -4,6 +4,7 @@ const ProcessLauncher = require('../process/processLauncher'); const utils = require('../utils/utils.js'); const constants = require('../constants'); + require("babel-preset-react"); require("babel-preset-es2015"); require("babel-preset-es2016"); @@ -25,8 +26,41 @@ class Pipeline { build(abi, contractsJSON, path, callback) { let self = this; const importsList = {}; + let placeholderPage; async.waterfall([ + function createPlaceholderPage(next){ + let html = ` + + + + ${__('Embark is building, please wait...')} + + + + +
+
+
+
+
+
+ + + + + + + + + +

${__('Embark is building, please wait...')}

+ + `; + fs.writeFile(self.buildDir + 'index.html', html, next); + }, function buildTheContracts(next) { self.buildContracts(next); }, @@ -141,11 +175,25 @@ class Pipeline { }).join("\n"); self.logger.info(__("writing file") + " " + (self.buildDir + targetFile).bold.dim); + if(new RegExp(/^index.html?/i).test(targetFile)){ + targetFile = targetFile.replace('index', 'index-temp'); + placeholderPage = targetFile; + } fs.writeFile(self.buildDir + targetFile, content, cb); } ); }, next); + }, + function removePlaceholderPage(next){ + let placeholderFile = self.buildDir + placeholderPage; + fs.access(self.buildDir + placeholderPage, (err) => { + if (err) return next(); // index-temp doesn't exist, do nothing + + // rename index-temp.htm/l to index.htm/l, effectively replacing our placeholder page + // with the contents of the built index.html page + fs.move(placeholderFile, placeholderFile.replace('index-temp', 'index'), {overwrite: true}, next); + }); } ], callback); }