caught error stops watching the files
radical-edo opened this issue · comments
I have the following config:
gulp.task('ngAnnotate', function() {
return gulp.src(paths.js)
.pipe(ngAnnotate({
add: true,
remove: true,
single_quotes: true
}).on('error', function(err) {
console.error(err.toString());
}))
.pipe(gulp.dest('./public'));
});
gulp.task('watch', function() {
gulp.watch(paths.js, ['ngAnnotate', 'jshint']);
});
It works, so far so good. But, if I make a syntax error, the error
will be caught and printed to the console - all good. However, the plugin won't watch the files. I have to restart the gulp
.
Without the simplest of error handling the gulp.watch
will just crash and will be forced to restart anyways, which will crash again until the error is found and dealt with.
Am I doing something wrong?
Ok, found the solution....
.on('error', function(err) {
console.error(err.toString());
this.emit('end');
})
This seems to do the trick.
Yea, you could either set error
handler or use gulp-plumber
plugin.