gulp-tap
gulp-tap copied to clipboard
Async onEnd doesn't run when called after tap
When I specify .on('end', callback)
after calling tap
the event callback will not be fired. One can get around this by specifying the event callback first but I am wondering if this is expected or a bug?
gulp.task('test', function() {
return gulp.src(paths.css)
.pipe(doSomething())
.on('end', tap(function() {
// this will be executed
console.log('Tasks done (A)')
}))
.pipe(tap(function(file) {
console.log(file);
}))
.on('end', tap(function() {
// this will not be executed
console.log('Tasks done (B)')
}))
});
bump
It works for me with simple
gulp.task('test', () =>
gulp.src(…).pipe(…).on('end')
)
but not with
gulp.task('test', (cb) =>
gulp.src(…).pipe(…).on('end', cb)
)
Sorry - don't have time to look into this at the moment. Perhaps @Javey, @mgutz, @revelt or @isiahmeadows could take a look if you have some spare time?
If only the code was decaffeinated...
Hi @flekschas . Firstly the callback for end event must be a function, so you should not use tap
which return a stream to bind. It works for me like bellow.
gulp.task('test', function() {
return gulp.src('./*.js')
.on('end', function() {
console.log(1);
})
.pipe(tap(function(file) {
console.log(file)
}))
.on('end', function() {
console.log(2);
});
});