gulp-useref
gulp-useref copied to clipboard
Unhandled stream error in transformStream
From reading code example, it is using lazypipe as transformStream, but lazypipe can only attach error listener after it is initialized. So I guess there is no way to capture transformStream's error in our gulpfile.
My situation is running a watch task for babel transformStream, once babel throw error a syntax error, it will exit the watch process, here is a short code example:
return gulp.src('./www/index.html')
.pipe(plugins.useref(
{},
lazypipe().pipe(function () {
return plugins.babel()
.on('error', onError);
});
));
In this case my onError won't end the transformStream as I wish.
My question is if we can add on('error') on those transformStream by default to emit('end') and let gulpfile handling the error itself. I would also appreciate any suggestion for how to handle this?
Thanks.
- You don't have to use lazypipe, just use a function, like
useref({}, function(name) { return babel() })
- What do you do on error? Why not emit
endinonError?