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

Tasks that return a Promise of a stream #79

Open
ineentho opened this issue May 18, 2017 · 2 comments
Open

Tasks that return a Promise of a stream #79

ineentho opened this issue May 18, 2017 · 2 comments

Comments

@ineentho
Copy link

Is there any particular reason why promises that resolve to a stream aren't supported? For example:

gulp.task('task', () => {
  return Promise.resolve().then(() => {
    return gulp.src(...).pipe(gulp.dest(...))
  })
})

Intuitively, I thought this would be supported, the same way that a Promise that resolves to a Promise waits for both.

Now that async/wait is supported in node, I'd say the case for supporting this is even stronger, take for example (very abstract, I know, but I'm sure you too can see a real world use case for this):

gulp.task('task', async () => {
  const config = await getConfigFromFile()
  return gulp.src(...)
    .pipe(doSomething(config))
    .pipe(gulp.dest(...))
})

Currently I'm using node-promisepipe to work around this, but I think this could be supported natively. Thoughts?

@robrich
Copy link
Owner

robrich commented May 18, 2017 via email

@ineentho
Copy link
Author

Sure, done. While I was at it, I noticed that because of the promise, all errors in the start callback were swallowed by the promise. Would it be desirable to run process.nextTick around the done.call in runTask to avoid that?

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