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

Merged streams don't continue #32

Closed
JacobDB opened this issue Oct 1, 2018 · 3 comments
Closed

Merged streams don't continue #32

JacobDB opened this issue Oct 1, 2018 · 3 comments

Comments

@JacobDB
Copy link

JacobDB commented Oct 1, 2018

I'm not sure if the title makes any sense, but I'll do my best to explain.

I've got a gulp task that loops through some folders and runs some processes against all the files in each folder. These get added together with merge-stream. Once each folder has been processed and merged back together in to one stream, I then want to emit a notification to indicate that the task ran and completed. However, it seems that nothing after return MERGED_STREAMS is firing.

My full scripts task can be found on my new-site repository, but this is the relevant bit:

return MERGED_STREAMS
    // prevent breaking on error
    .pipe(plugins.plumber({
        errorHandler: on_error,
    }))
    // notify that task is complete, if not part of default or watch
    .pipe(plugins.gulpif(gulp.seq.indexOf("scripts") > gulp.seq.indexOf("default"), plugins.notify({
        title:   "Success!",
        message: "Scripts task complete!",
        onLast:  true,
    })))
    // push task to ran_tasks array
    .on("data", () => {
        if (ran_tasks.indexOf("scripts") < 0) {
            ran_tasks.push("scripts");
        }
    })
    .on("end", () => {
        console.log("reached the end"); // never happens
        return resolve();
    });

Any idea what could be causing this? I'm at a complete loss.

@JacobDB
Copy link
Author

JacobDB commented Oct 10, 2018

I figured out a different approach to accomplish what I was trying to do, but would still like to know what the problem is.

@grncdr
Copy link
Owner

grncdr commented Nov 26, 2018

I'm not familiar with what most of these gulp things you're using do, but I noticed this:

plugins.gulpif(gulp.seq.indexOf("scripts") > gulp.seq.indexOf("default"), ...)

It seems likely to me that doesn't do what you want, since the conditon is only evaluated once when your program starts.

@JacobDB
Copy link
Author

JacobDB commented Nov 27, 2018

So that stuff is to handle different notifications; I notify for each individual task, but combine them in to one notification when gulp or gulp watch is ran. Never had any issues with that in the past, still working well today.

I'm going to go ahead and close this issue, I think the problem was that a promise was returning too early and breaking things.

@JacobDB JacobDB closed this as completed Nov 27, 2018
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

2 participants