From 2a7f1d63685ec58a70ac076805e0d3df69d52da4 Mon Sep 17 00:00:00 2001 From: Raghu Simha Date: Mon, 5 Feb 2018 17:47:46 -0500 Subject: [PATCH] Fail build on error, and print a useful message (#13255) --- gulpfile.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 7247fc26f2b9..7a1305558050 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -992,11 +992,10 @@ function compileJs(srcDir, srcFilename, destDir, options) { const startTime = Date.now(); return toPromise(bundler.bundle() .on('error', function(err) { - if (err instanceof SyntaxError) { - console.error(red('Syntax error: ' + err.message)); - } else { - console.error(red(err.message)); - } + // Drop the node_modules call stack, which begins with ' at'. + const message = err.stack.replace(/ at[^]*/, '').trim(); + console.error(red(message)); + process.exit(1); }) .pipe(lazybuild()) .pipe($$.rename(destFilename))