From 52c6d5290e5654c2df02d87ef04f52fa6411b846 Mon Sep 17 00:00:00 2001 From: Raghu Simha Date: Tue, 6 Feb 2018 18:05:11 -0500 Subject: [PATCH] Don't cancel watch if an edit causes a compilation error (#13312) --- gulpfile.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 20391318cee8..22078f610176 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -993,7 +993,7 @@ function compileJs(srcDir, srcFilename, destDir, options) { .pipe(gulp.dest.bind(gulp), destDir); const destFilename = options.toName || srcFilename; - function rebundle() { + function rebundle(failOnError) { const startTime = Date.now(); return toPromise( bundler.bundle() @@ -1001,7 +1001,11 @@ function compileJs(srcDir, srcFilename, destDir, options) { // Drop the node_modules call stack, which begins with ' at'. const message = err.stack.replace(/ at[^]*/, '').trim(); console.error(red(message)); - process.exit(1); + if (failOnError) { + process.exit(1); + } else { + endBuildStep('Error while compiling', srcFilename, startTime); + } }) .pipe(lazybuild()) .pipe($$.rename(destFilename)) @@ -1029,7 +1033,7 @@ function compileJs(srcDir, srcFilename, destDir, options) { if (options.watch) { bundler.on('update', function() { - rebundle(); + rebundle(/* failOnError */ false); // Touch file in unit test set. This triggers rebundling of tests because // karma only considers changes to tests files themselves re-bundle // worthy. @@ -1046,7 +1050,7 @@ function compileJs(srcDir, srcFilename, destDir, options) { } else { // This is the default options.watch === true case, and also covers the // `gulp build` / `gulp dist` cases where options.watch is undefined. - return rebundle(); + return rebundle(/* failOnError */ true); } }