Open medikoo opened 8 years ago
I would like this too, but I don't think it's possible. From what I can remember, the stdio inheriting logic is done in native code in libuv, not in ChildProcess.prototype.spawn
. But happy to be proven wrong in the form of a pull request 😀.
@sindresorhus I investigated it and indeed it looks there's no way. Still I would leave it open, maybe other adventurers will find some miraculous solution.
Sure
As a passer-by who hit this issue, I don't know if future folks have the same kind of problems as me (I wanted guarantees that I was getting pretty much the exact stdout/stderr with ASNI, but not spamming the console.)
What I did instead was use node-pty to spawn an in-memory pseudo-terminal which I could extract pretty much the exact same stdout/stderr.
@orta Yup. That works, but node-pty
is a native Node.js addon, which comes with all kinds of problems. It's not something I would depend on in a reusable package. If only Node.js had PTY built-in...
It might be nice to somehow support that, at least via option.
Without that, output that hook-std captures doesn't necessary cover all output as seen from initialized process in a console.
I think it's possible only via overriding
ChildProcess.prototype.spawn
and act accordingly after recognizing the intention.