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

Stream doesn't end when using fn as condition. #61

Open
bfricka opened this issue Dec 17, 2015 · 3 comments
Open

Stream doesn't end when using fn as condition. #61

bfricka opened this issue Dec 17, 2015 · 3 comments

Comments

@bfricka
Copy link

bfricka commented Dec 17, 2015

When I use a function as condition, stream never ends. An example probably works best.

In this case, everything ends up in dist, and stream ends.

gulp.task('copy', function() {
  return gulp
    .src('path/to/stuff')
    .pipe(gulpif(false, fail())
    .pipe(gulp.dest('dist');
});

So in console you see:

Staring 'copy'...
Finished 'copy' after 4ms

In the function case everything still ends up in dist, but stream doesn't end.

function returnfalse() { return false }
gulp.task('copy', function() {
  return gulp
    .src('path/to/stuff')
    .pipe(gulpif(returnfalse, fail())
    .pipe(gulp.dest('dist');
});

In console you see:

Starting 'copy'...
[process exits]

Obviously this is an issue because we need the stream to end for other tasks to know it completed (it can't be a dependency task otherwise).

Am I doing something wrong? It seems like these cases should behave identically.

@robrich
Copy link
Owner

robrich commented Dec 18, 2015 via email

@bfricka
Copy link
Author

bfricka commented Dec 18, 2015

Sure, I created a repo that shows each scenario. Had to point to a different version of gulp-fail since that was broken also.

Run through each task. When fail is invoked we don't expect the stream to end of course (since we exit early). But when we move through successfully, end should be called, and yet it is only called when a a boolean is passed. I've seen this a number of times, and clearly whoever created gulp-exit has also. If I have time, I'll track it down, and submit a PR, but currently I don't have the time.

FWIW this is running in node v5.2

@jcvignoli
Copy link

I'm wondering if 6 years later, there is a solution... as I face the same problem.

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

3 participants