-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
Make retrieving the subprocess asynchronous #46
Conversation
} catch (error) { | ||
throw getResultError({ | ||
error, | ||
result: initResult(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the subprocess throws during spawn()
, we don't have access to the .stdout
and .stderr
stream properties. So the only way to know whether result.stdout
/result.stderr
should be undefined
or not is to check whether spawnOptions.stdout
is either "pipe"
or "overlapped"
.
We could do that check, but to save some bytes, this PR is making result.stdout
/result.stderr
an empty string instead of undefined
when using things like stdout: 'ignore'
or stdout: 'inherit'
. Also, this would make types simpler and smaller. Finally, it could be slightly simpler for users to assume those properties are always strings.
On the other hand, there are some benefits in the "undefined
vs empty string" distinction that Execa is making with result.stdout
. So I'm not sure whether that's a good idea or not. 🤔 Please let me know what you think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think empty strings are the best choice here, and would be for execa
too.
c16ba0b
to
9628e59
Compare
Fixed merge conflict. |
I agree. That's a better choice. |
Fixes #43.
Trying to keep the code small, although it's hard sometimes! :)
I've named the property
.nodeChildProcess
instead of.subprocess
following your comment here: sindresorhus/execa#413 (comment). Also this would allow us to name the main return valuesubprocess
instead ofpromise
in the documentation, which might be easier to understand. Please let me know if this sounds good.For example, we could document it along the following lines: