OverZealous/lazypipe

Gulp util .combine?

Closed this issue · 2 comments

I stumbled on this project, and was wondering: how is this different as the combine method from gulp-util?

It's very different, and it has been discussed that gulp-util.combine is deprecated due to how it creates unexpected errors.

The combine method takes a series of streams that have already been created, and chains them into one stream. This can lead to issues where you want to reuse a given set of streams in different ways. If you have, for example:

var group1 = gutil.combine(A(), B());

// later in task A
gulp.src(...).pipe(group1()).pipe(gulp.dest('build'));

// in task B
gulp.src(...).pipe(group1()).pipe(gulp.dest('dist'));

What happens when you run either task is that the result may be piped to both build and dist simultaneously.

Lazypipe, on the other hand, doesn't actually create the substreams until the moment it is called. This means you can reuse a lazypipe over and over, but know you are getting a different set of substreams every time. It has a tiny benefit of waiting to create a stream until it's actually going to be used.

You can still pass in stream arguments, simply by adding them as additional arguments to the lazypipe().pipe() method.

I see, very interesting. This issue with gutil.combine may be what causes some bug which I am experiencing. I have a quite extensive build script which defines several builds. Everything works perfectly, until I try to run more than 1 build in one gulp task. I'll try lazypipe to see if that solves the problem :).