I'm running gulp 3.6.2 and have the following task that was set up from a sample online
gulp.task('watch', ['default'], function () {
gulp.watch([
'views/**/*.html',
'public/**/*.js',
'public/**/*.css'
], function (event) {
return gulp.src(event.path)
.pipe(refresh(lrserver));
});
gulp.watch(['./app/**/*.coffee'],['scripts']);
gulp.watch('./app/**/*.scss',['scss']);
});
Any time there's an error in my CoffeeScript gulp watch stops - obviously not what I want.
As recommended elsewhere I tried this
gulp.watch(['./app/**/*.coffee'],['scripts']).on('error', swallowError);
gulp.watch('./app/**/*.scss',['scss']).on('error', swallowError);
function swallowError (error) { error.end(); }
but it doesn't seem to work.
What am I doing wrong?
In response to @Aper?u's answer I modified my swallowError
method and tried the following instead:
gulp.task('scripts', function () {
gulp.src('./app/script/*.coffee')
.pipe(coffee({ bare: true }))
.pipe(gulp.dest('./public/js'))
.on('error', swallowError);
});
Restarted, and then created a syntax error in my coffee file. Same issue:
[gulp] Finished 'scripts' after 306 μs
stream.js:94
throw er; // Unhandled stream error in pipe.
^
Error: W:ariokartappscriptrishell.coffee:5:1: error: unexpected *
*
^
at Stream.modifyFile (W:ariokart
ode_modulesgulp-coffeeindex.js:37:33)
at Stream.stream.write (W:ariokart
ode_modulesgulp-coffee
ode_modulesevent-stream
ode_moduleshroughindex.js:26:11)
at Stream.ondata (stream.js:51:26)
at Stream.EventEmitter.emit (events.js:95:17)
at queueData (W:ariokart
ode_modulesgulp
ode_modulesvinyl-fs
ode_modulesmap-streamindex.js:43:21)
at next (W:ariokart
ode_modulesgulp
ode_modulesvinyl-fs
ode_modulesmap-streamindex.js:71:7)
at W:ariokart
ode_modulesgulp
ode_modulesvinyl-fs
ode_modulesmap-streamindex.js:85:7
at W:ariokart
ode_modulesgulp
ode_modulesvinyl-fslibsrcufferFile.js:8:5
at fs.js:266:14
at W:ariokart
ode_modulesgulp
ode_modulesvinyl-fs
ode_modulesgraceful-fsgraceful-fs.js:104:5
at Object.oncomplete (fs.js:107:15)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…