Closed backflip closed 9 years ago
I've actually been working on replacing map-stream
with through2.obj
. That change plus gulp-plumber
provides a Gulp 3 solution until Gulp 4 (and its improved error handling) is released.
Does that sound reasonable?
Even better. Any helping hands appreciated/wanted? Or are you almost through with it anyway?
Thanks! I've got the switch to through2
made, but I want to get a fix for #15 in before release, as you'll likely need that too.
Released switch to through2 as v2.4.0.
This still crashes when throwing an error. I guess instead of calling the template
function directly, it should be wrapped with a try/catch:
try {
file.contents = new Buffer(template(context));
} catch (err) {
this.emit('error', err);
}
@backflip I'll get the error handling updated, but even so, you'll need to use gulp-plumber
until Gulp 4 is released. There was a patch to make gulp.watch
in Gulp 3 work a little better, but it's still broken.
var gulp = require('gulp'),
plumber = require('gulp-plumber'),
hb = require('gulp-hb');
gulp.task('html', function () {
return gulp
.src('./src/**/*.hbs')
.pipe(plumber())
.pipe(hb())
.pipe(gulp.dest('./web'));
});
gulp.task('watch', function () {
gulp.watch('./src/**/*.hbs', ['html']);
});
Improved error handling published as v2.4.2
Perfect, thanks!
Currently, the stream ends when an error occurs. This is undesirable when having a watch process running, e.g.
A solution is to use the
failures
option ofmap-stream
which was added for this case: https://github.com/dominictarr/map-stream/pull/7What do you think?