Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async onEnd doesn't run when called after tap #18

Open
flekschas opened this issue Aug 13, 2017 · 5 comments
Open

Async onEnd doesn't run when called after tap #18

flekschas opened this issue Aug 13, 2017 · 5 comments

Comments

@flekschas
Copy link

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)')
        }))
});
@timc13
Copy link

timc13 commented Feb 20, 2018

bump

@Kagami
Copy link

Kagami commented Mar 20, 2018

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)
)

@dotnetCarpenter
Copy link
Collaborator

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?

@revelt
Copy link
Contributor

revelt commented Mar 20, 2018

If only the code was decaffeinated...

@Javey
Copy link
Contributor

Javey commented Mar 21, 2018

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);
        });
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants