execa
execa copied to clipboard
Stdio `tap` option
For stderr
and stdout
the choice between inherit
and pipe
, has tradeoffs.
Specifically, if you choose inherit
, you loose the ability to observe the stream, it's piped straight to the parents stdout/stderr.
I propose we add a tap
option. It will be converted internally to the pipe
option, but we will grab the pipe, split it into two streams, one stream we pipe directly to stdout/stderr
, the other we make available for observation.
Yes! I've always wanted this 😀
That also means you can do use execa()
with inherit
and get it written directly console, while still getting the stdout/stderr in the promise.
One downside with piping vs inherit: You lose the tty
support.
We fake tty
for forked processes in AVA. We could reimplement that for execa
, but it involves some magic and would only work for Node sources. Maybe opt-in via an option?
Maybe opt-in via an option?
👍 You should make the fake TTY thing in AVA a reusable module we can use here too.
If only Node.js had PTY
support...
(tl;dr It would let us pretend to be a terminal when spawning a child process).
There is pty.js
- I've used it before and it works. It's got a native component though.
Maybe we could try incorporating that as an optional/peer dependency. If they try to fork a non-node module, it tries to require it (and if it fails it fails - give them a decent error message explaining pty.js
is required to make non-node executables work).
Or maybe that is too much effort for what may be a niche case.
There is pty.js - I've used it before and it works.
I'm aware. I've used it too.
It's got a native component though.
That's why it's not a solution for me. Native dependencies are too much hassle.
Or maybe that is too much effort for what may be a niche case.
Yeah. Not worth it, and would be weird with varying behavior. I'd rather see it builtin in Node.js, and I'm planning to open a ticket convincing them when I have time.
Done in #643: one can now use stdout: ['inherit', 'pipe']
to get that behavior. This works also with stderr
and stdin
.