teambition / merge2

Merge multiple streams into one stream in sequence or parallel (~119M/month downloads).
MIT License
170 stars 14 forks source link

Cannot switch to old mode #9

Closed pyrsmk closed 7 years ago

pyrsmk commented 8 years ago

Hi!

I've a weird issue when using merge2. It seems it comes from the fact I'm splitting my stream pipes. But I'm not sure how to fix this, and how to do this differently...

var streams = require('merge2')(),
requireTree = function(name) {
    var stream = gulp.src( components[name] + '/component.scss' );
    if(fs.existsSync(components[name] + '/require.json')) {
        var deps = require(components[name] + '/require.json'),
            i, j;
        for(i=deps.length-1, j=0; i>=j; --i) {
            requireTree(deps[i]);
            stream.pipe( insert.append('@import "' + components[deps[i]] + '/component.scss";') );
        }
    }
    stream.pipe( gulp.dest(rootPath + '/cache/scss/' + name) );
    streams.add(stream);
};
jjalonso commented 8 years ago

Same here.

That happened as well the same with "streamqueue" lib, then I can guess is something of node, but... How to avoid it or why ?

Thanks.

pyrsmk commented 8 years ago

Personally, I fixed the issue without not really fixing it but by structuring my code differently ^^

jjalonso commented 8 years ago

I came again back to 'streamqueue' and I discovered was the .queue() or .add() (depend of beach lib) the guilty of the error.

But if you deliver all gulp src in the constructor everything works.

Then... Because I had and array... I called the constructor with apply() to spread the streams array as comma separated arguments.

On 14 Oct 2016 1:47 pm, "Aurélien Delogu" notifications@github.com wrote:

Personnally, I fixed the issue without not really fixing it but by structuring my code differently ^^

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/teambition/merge2/issues/9#issuecomment-253789898, or mute the thread https://github.com/notifications/unsubscribe-auth/AAXxW-h8q8fgDnZEmKsqe-2cUTBbEhL9ks5qz3nMgaJpZM4KQw5K .