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

return the child process instead of a promise. #18

Merged
merged 3 commits into from
Apr 24, 2016

Conversation

jamestalmage
Copy link
Contributor

We are guessing at the desired properties of the child-process object.

Instead, why not just copy over .then and .catch from the promise to spawned and return that.

This would allow stuff like this:

var spawned = execa('./cli.js');
spawned.stdin.write('foo');
spawned.stdin.end();

const {stdout} = await spawned;

We are guessing at the desired properties of the child-process object.

Instead, why not just copy over `.then` and `.catch` from the promise to `spawned` and return that.

This would allow stuff like this:

```js
var spawned = execa('./cli.js');
spawned.stdin.write('foo');
spawned.stdin.end();

const {stdout} = await spawned;
```
@kevva
Copy link
Contributor

kevva commented Apr 23, 2016

This is pretty cool 👍

@sindresorhus
Copy link
Owner

👍 That's a cool idea! I always forget you can thenify something.

@sindresorhus
Copy link
Owner

Can you update the docs? Mainly update what the methods return and remove The promise instance has a pid property (ID of the child process) and a kill method (for sending signals to the child process)..

@jamestalmage
Copy link
Contributor Author

Go ahead and merge #14. I'll update this once it's merged so execa.stdout(...) returns a thenified child process as well.

@jamestalmage
Copy link
Contributor Author

Can you update the docs?

Yes, absolutely. I was just getting this out there as an idea. It was easier to do a PR than open an issue in this case.

@sindresorhus
Copy link
Owner

@jamestalmage Go ahead and finish this. I'm not ready to merge #14 yet. Haven't decided whether #14 is worth the extra API bloat and overhead.

@jamestalmage
Copy link
Contributor Author

Haven't decided whether #14 is worth the extra API bloat and overhead.

I think it is. Specifically, if someone does execa.stdout, then we can set stderr to 'ignore' or maybe inherit. This would be useful if some program prints some very verbose debugging information that we don't want causing buffer overruns.

Go ahead and finish this

Will do

@jamestalmage
Copy link
Contributor Author

Docs updated.

@sindresorhus
Copy link
Owner

tumblr_mkwooez15j1qdlh1io1_400

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

Successfully merging this pull request may close these issues.

3 participants