grncdr / merge-stream

Merge multiple streams into one interleaved stream
MIT License
214 stars 16 forks source link

2 Streams never end - while each stream separately does #30

Closed geri777 closed 5 years ago

geri777 commented 6 years ago

I have the following script:

gulp.task('htmlscripts', ['cleanup'], function() {
    var allStreams = [
    gulp.src(['*.html', '!index.html'])
        .pipe(useref())
        .pipe(cache('useref'))
        .pipe(gulp.dest(distFolder)),
    gulp.src('index.html')
        .pipe(useref())
        .pipe(cache('useref'))
        .pipe(gulpif('*.js',
            uglify()
        ))
        .pipe(gulpif('*.css',
            cleanCSS()
        ))
        .pipe(gulp.dest(distFolder))
    ];
    return merge.apply(this, allStreams);
});

If I comment out one of the two streams, the merge fires the end event - if I have both streams in the merge, all further dependencies are not started. I use merge-stream in other tasks where it works perfectly. I have no clue what's wrong here - maybe one of the pipes do not return properly?

PS: If you don't like the merge.apply syntax - don't worry, I tested the problem with merge(var1, var2) as well and it's the same.

grncdr commented 5 years ago

Closing this because it's probably very stale. If it turns out this is still an issue that needs investigation, please re-open with a more minimal reproduction.

anderoonies commented 4 years ago

@geri777 did you ever resolve this? i'm having the same issue

geri777 commented 4 years ago

@anderoonies, I cannot exactly remember, but I think you should check the following:

instead of...

uglify()

use

uglify().on('error', function(e){
    console.log("Uglify Error - maybe you are using ES6 Code?")
    console.log(e);
})

Finally you could just try another version of gulp and merge-stream. This is my config in a project which works: gulp--version tells me CLI version 2.1.0. And my merge-stream version is 1.0.1

anderoonies commented 4 years ago

thanks @geri777 :) i ended up adding an .on('end', this.emit('unpipe')) to the individual pipes and it ended up working

stevemao commented 4 years ago

@geri777 @anderoonies Please send a PR to fix it if possible. Thanks a lot!