Add API to worker thread to check whether main thread is TTY
还没有人认领这个 Issue。
- 主要语言
- JavaScript
- 星标
- 122k
- 派生
- 37.3k
- 平均合并
- 4 天 2 小时
- 30 天内合并 PR
- 283
描述
What is the problem this feature will solve?
In worker threads, process.stdout.isTTY and process.stderr.isTTY are undefined. However, they do forward stdout/stderr to the main thread, and the main thread could potentially be isTTY === true. This makes sense as some things don't work, like raw mode. However, things that produce colors would want to be able to detect that the main thread is TTY, so colors can be shown when logged from a worker thread.
What is the feature you are proposing to solve the problem?
Add an API to worker threads to check whether stdout/stderr in the main thread is TTY.
This is needed for color packages like chalk to be able to support showing colors when running in worker threads.
Relevant issue: https://github.com/nodejs/node/issues/26946
What alternatives have you considered?
No response
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
先阅读 worker_threads API 和相关 issue #26946,然后跟踪从 worker 转发输出时 process.stdout.isTTY 和 process.stderr.isTTY 的行为。当提议的 worker-thread API 能够检测主线程 stdout 和 stderr 的 TTY 状态,并覆盖 color-package 的使用场景时,即视为完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript
- 领域
- backend-api-design
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 活跃
- 描述清晰度
- 基本清楚
- 新手友好度
- 48/100