gulpjs / async-done

Allows libraries to handle various caller provided asynchronous functions uniformly. Maps promises, observables, child processes and streams, and callbacks to callback style.
MIT License
70 stars 21 forks source link

Promise that resolves to Stream or ChildProcess? #50

Closed apowers313 closed 5 years ago

apowers313 commented 5 years ago

Would it be acceptable to have async-done wait on a Stream or a ChildProcess that is the result of a resolved promise?

Use case is like this:

async function myTask() {
    await someSetup();
    return gulp.src(/*...*/).pipe(/*...*/);
}

Happy to submit a PR if this is a good idea.

phated commented 5 years ago

You really really really don't want to combine different types of asynchronousity like that. You'd be opening yourself to a world of bugs and other issues.

If you want to do this in gulp, just keep it simple:

let config;

async function setup() {
    config = await someSetup();
}

const myTask = gulp.series(setup, function() {
    return gulp.src(/*...*/).pipe(/*...*/);
});