From 2673c2196b84f6818ae4cd7b7200984d726428c7 Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Thu, 1 Dec 2016 20:30:47 +0000 Subject: [PATCH] Use synchronous mkdirs when building UI Also add explicit promise error handling. --- scripts/build_ui.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/scripts/build_ui.js b/scripts/build_ui.js index 14d00518..512ee17d 100644 --- a/scripts/build_ui.js +++ b/scripts/build_ui.js @@ -5,6 +5,11 @@ const fs = require('fs-extra'); const path = require('path'); const getRobotoFiles = require('./get_roboto_files').getRobotoFiles; +function handleError(error) { + console.error(error); + process.exit(1); +} + function getHtmlImports(filePath) { return hyd.Analyzer.analyze(filePath).then((analyzer) => analyzer._getDependencies(filePath) @@ -69,7 +74,7 @@ function normalisePaths(html) { function copyNormalisedFile(sourceFile, destinationFile) { const html = fs.readFileSync(sourceFile, { encoding: 'utf8' }); - fs.mkdirs(path.dirname(destinationFile)); + fs.mkdirsSync(path.dirname(destinationFile)); fs.writeFileSync(destinationFile, normalisePaths(html)); } @@ -83,7 +88,7 @@ function copyFiles(pathsPromise, destinationRootPath) { copyNormalisedFile(filePath, destinationPath); } }); - }); + }).catch(handleError); } const url = 'https://github.com/google/roboto/releases/download/v2.135/roboto-hinted.zip'; @@ -113,4 +118,4 @@ Promise.resolve().then(() => { const webAnimationsJs = 'bower_components/web-animations-js/web-animations-next-lite.min.js'; fs.copySync(webAnimationsJs, `${destinationRootPath}/${webAnimationsJs}`); }); -}); +}).catch(handleError);