Pretend to be a TTY
- Dominant language
- TypeScript
- Stars
- 6.4k
- Forks
- 128
- Avg merge
- 4d 10h
- Merged PRs (30d)
- 4
Description
Some tools produce different output when they detect that terminal is not a TTY (interactive). For example, TypeScript produces colorized output by default only in TTY mode. Otherwise the `--pretty` flag must be specified to force colorized output.
When a process is run via Wireit, the process will think it is not attached to a TTY, because we use the default `pipe` setting to handle stdio from `spawn` (https://nodejs.org/api/child_process.html#optionsstdio), so it isn't attached to a TTY directly. We could instead use `inherit`, but that would not allow us to capture the output, which we need for storing stdio replays.
A downside of this is that it does not match the standard behavior of `npm run`, which uses `inherit`. Matching the behavior of npm is one of our goals.
Using a library like https://github.com/microsoft/node-pty may be the only way to trick processes into thinking they are attached to a TTY, while also being able to capture the output for the replay files. We should do a little more research to confirm this, as there is a chance there is a simpler solution. This library is somewhat large, includes a native library, and has a different interface to `spawn`. Note we would only want to do this when we detect _we_ are running in a TTY.
Contributor guide
Assessment
This issue has not been assessed yet.