-
-
Notifications
You must be signed in to change notification settings - Fork 214
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
Better stdio option handling - fixes #24 #80
Conversation
readme.md
Outdated
Type: `string`<br> | ||
Default: `pipe` | ||
|
||
Configure the `stderr` pipe. |
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.
We should link to the relevant Node docs and provide a reminder of the available options: https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio
We should also allow positive integers, undefined
, and null
.
Made a little change to the docs, is this better? Or should we do something like
|
That works. Do we have tests making sure we cover the number and stream scenarios? |
I will have a look tomorrow to cover that. Any ideas how we could test the streams? |
Hmmm. Using streams with I am working on a module to reliably detect those types of streams. (stealing from the code here). If they pass a userland stream, I think we can still accommodate, but it's more of a PITA. |
Just go with this for now. We can discuss providing more user friendly stream handling later |
Added 2 more types of tests
I was looking into the stream thing before I read your comment. From the docs
So I was expecting I could do something like this const writeStream = fs.createWriteStream('file.txt');
await execa('foo', {stdout: writeStream}); But as you figured out, that is not possible. |
test('pass `stderr` to a file descriptor', async t => { | ||
const file = tempfile('.txt'); | ||
await m('fixtures/noop-err', ['foo bar'], {stderr: fs.openSync(file, 'w')}); | ||
t.is(fs.readFileSync(file, 'utf8'), 'foo bar\n'); |
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.
Ah. Good test strategy. File streams are allowed. I opened an issue to handle userland streams better
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.
Wait, I missed your comment. So this is just a descriptor, not a stream. The way child_process
handles streams just gets weirder and weirder
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.
Yes exactly. Either the docs are wrong, or I did it wrong. But the docs link to Stream which states
Incorrect value for stdio stream: WriteStream
But but... Ugh, nevermind.
I like it. Let's merge |
Cherry picked from #36 (Thanks @jamestalmage for the initial work!).
Also fixed some issues regarding #79 as it didn't support
stdio
to being an Array.Feel free to provide feedback on anything, not sure about the docs either.