nodejs / nodejs/node

Add API to worker thread to check whether main thread is TTY

オープン
#51,750 コメント 13 件 リアクション 6 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

feature request never-stale worker
主要言語
JavaScript
スター
122k
フォーク
37.3k
平均マージ
4日 2時間
マージ済み PR(30日)
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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. 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
見積もり時間
1週間以上
活発さ
活発
明瞭さ
おおむね明確
初心者へのやさしさ
48/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。