Skip to content

Commit

Permalink
Don't cancel watch if an edit causes a compilation error (ampproject#…
Browse files Browse the repository at this point in the history
  • Loading branch information
rsimha authored and protonate committed Feb 26, 2018
1 parent 161bac8 commit 92ce77a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -993,15 +993,19 @@ 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()
.on('error', function(err) {
// 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))
Expand Down Expand Up @@ -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.
Expand All @@ -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);
}
}

Expand Down

0 comments on commit 92ce77a

Please sign in to comment.