node icon indicating copy to clipboard operation
node copied to clipboard

lib: respect terminal capabilities on styleText

Open RafaelGSS opened this issue 1 year ago • 17 comments

This PR changes styleText API to respect terminal capabilities and environment variables such as NO_COLOR, NODE_DISABLE_COLORS, and FORCE_COLOR.

I talked with @edsadr about taking over from https://github.com/nodejs/node/pull/51959.

Fixes: https://github.com/nodejs/node/issues/54365

RafaelGSS avatar Aug 14 '24 23:08 RafaelGSS

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 87.33%. Comparing base (123693c) to head (5efe9b8). Report is 132 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #54389      +/-   ##
==========================================
+ Coverage   87.10%   87.33%   +0.23%     
==========================================
  Files         648      649       +1     
  Lines      182215   182642     +427     
  Branches    34955    35044      +89     
==========================================
+ Hits       158712   159506     +794     
+ Misses      16789    16402     -387     
- Partials     6714     6734      +20     
Files with missing lines Coverage Δ
lib/util.js 95.78% <100.00%> (+0.49%) :arrow_up:

... and 81 files with indirect coverage changes

codecov[bot] avatar Aug 20 '24 15:08 codecov[bot]

CI: https://ci.nodejs.org/job/node-test-pull-request/61293/

nodejs-github-bot avatar Aug 20 '24 17:08 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/61298/

nodejs-github-bot avatar Aug 20 '24 20:08 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/61329/

nodejs-github-bot avatar Aug 21 '24 19:08 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/61334/

nodejs-github-bot avatar Aug 21 '24 21:08 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/61346/

nodejs-github-bot avatar Aug 22 '24 13:08 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/61354/

nodejs-github-bot avatar Aug 22 '24 18:08 nodejs-github-bot

Commit Queue failed
- Loading data for nodejs/node/pull/54389
✔  Done loading data for nodejs/node/pull/54389
----------------------------------- PR info ------------------------------------
Title      lib: respect terminal capabilities on styleText (#54389)
Author     Rafael Gonzaga <[email protected]> (@RafaelGSS)
Branch     RafaelGSS:support-tty-no-colors-styleText -> nodejs:main
Labels     util, author ready, needs-ci
Commits    7
 - lib: respect terminal capabilities on styleText
 - fixup! lib: respect terminal capabilities on styleText
 - fixup! fixup! lib: respect terminal capabilities on styleText
 - fixup! fixup! fixup! lib: respect terminal capabilities on styleText
 - fixup! fixup! lib: respect terminal capabilities on styleText
 - fixup! fixup! lib: respect terminal capabilities on styleText
 - fixup! lib: respect terminal capabilities on styleText
Committers 1
 - RafaelGSS <[email protected]>
PR-URL: https://github.com/nodejs/node/pull/54389
Fixes: https://github.com/nodejs/node/issues/54365
Reviewed-By: Moshe Atlow <[email protected]>
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/54389
Fixes: https://github.com/nodejs/node/issues/54365
Reviewed-By: Moshe Atlow <[email protected]>
--------------------------------------------------------------------------------
   ⚠  Commits were pushed since the last approving review:
   ⚠  - fixup! fixup! lib: respect terminal capabilities on styleText
   ⚠  - fixup! fixup! fixup! lib: respect terminal capabilities on styleText
   ⚠  - fixup! fixup! lib: respect terminal capabilities on styleText
   ⚠  - fixup! fixup! lib: respect terminal capabilities on styleText
   ⚠  - fixup! lib: respect terminal capabilities on styleText
   ℹ  This PR was created on Wed, 14 Aug 2024 23:02:26 GMT
   ✔  Approvals: 1
   ✔  - Moshe Atlow (@MoLow) (TSC): https://github.com/nodejs/node/pull/54389#pullrequestreview-2241573413
   ✔  Last GitHub CI successful
   ℹ  Last Full PR CI on 2024-08-22T18:07:12Z: https://ci.nodejs.org/job/node-test-pull-request/61354/
- Querying data for job/node-test-pull-request/61354/
   ✔  Last Jenkins CI successful
--------------------------------------------------------------------------------
   ✔  Aborted `git node land` session in /home/runner/work/node/node/.ncu
https://github.com/nodejs/node/actions/runs/10531270448

nodejs-github-bot avatar Aug 23 '24 19:08 nodejs-github-bot

Uh almost missed @targos suggestion. Will do it tomorrow.

RafaelGSS avatar Aug 24 '24 17:08 RafaelGSS

@targos @RafaelGSS lmk if it's fine to add the commit-queue label :)

ovflowd avatar Aug 24 '24 18:08 ovflowd

CI: https://ci.nodejs.org/job/node-test-pull-request/61428/

nodejs-github-bot avatar Aug 24 '24 22:08 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/61457/

nodejs-github-bot avatar Aug 25 '24 20:08 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/61459/

nodejs-github-bot avatar Aug 25 '24 20:08 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/61492/

nodejs-github-bot avatar Aug 26 '24 14:08 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/61510/

nodejs-github-bot avatar Aug 26 '24 19:08 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/61518/

nodejs-github-bot avatar Aug 27 '24 00:08 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/61554/

nodejs-github-bot avatar Aug 27 '24 15:08 nodejs-github-bot

Commit Queue failed
- Loading data for nodejs/node/pull/54389
✔  Done loading data for nodejs/node/pull/54389
----------------------------------- PR info ------------------------------------
Title      lib: respect terminal capabilities on styleText (#54389)
Author     Rafael Gonzaga <[email protected]> (@RafaelGSS)
Branch     RafaelGSS:support-tty-no-colors-styleText -> nodejs:main
Labels     util, author ready, needs-ci
Commits    8
 - lib: respect terminal capabilities on styleText
 - fixup! lib: respect terminal capabilities on styleText
 - fixup! fixup! lib: respect terminal capabilities on styleText
 - fixup! fixup! fixup! lib: respect terminal capabilities on styleText
 - fixup! fixup! lib: respect terminal capabilities on styleText
 - fixup! fixup! lib: respect terminal capabilities on styleText
 - fixup! lib: respect terminal capabilities on styleText
 - fixup! doc: added missing options
Committers 2
 - RafaelGSS <[email protected]>
 - GitHub <[email protected]>
PR-URL: https://github.com/nodejs/node/pull/54389
Fixes: https://github.com/nodejs/node/issues/54365
Reviewed-By: Moshe Atlow <[email protected]>
Reviewed-By: Claudio Wunder <[email protected]>
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/54389
Fixes: https://github.com/nodejs/node/issues/54365
Reviewed-By: Moshe Atlow <[email protected]>
Reviewed-By: Claudio Wunder <[email protected]>
--------------------------------------------------------------------------------
   ⚠  Commits were pushed since the last approving review:
   ⚠  - fixup! doc: added missing options
   ℹ  This PR was created on Wed, 14 Aug 2024 23:02:26 GMT
   ✔  Approvals: 2
   ✔  - Moshe Atlow (@MoLow) (TSC): https://github.com/nodejs/node/pull/54389#pullrequestreview-2241573413
   ✔  - Claudio Wunder (@ovflowd): https://github.com/nodejs/node/pull/54389#pullrequestreview-2258107034
   ✔  Last GitHub CI successful
   ℹ  Last Full PR CI on 2024-08-27T15:59:07Z: https://ci.nodejs.org/job/node-test-pull-request/61554/
- Querying data for job/node-test-pull-request/61554/
   ✔  Last Jenkins CI successful
--------------------------------------------------------------------------------
   ✔  Aborted `git node land` session in /home/runner/work/node/node/.ncu
https://github.com/nodejs/node/actions/runs/10599637336

nodejs-github-bot avatar Aug 28 '24 15:08 nodejs-github-bot

I might need the approvals again after the last fixup.

RafaelGSS avatar Aug 28 '24 15:08 RafaelGSS

Commit Queue failed
- Loading data for nodejs/node/pull/54389
✔  Done loading data for nodejs/node/pull/54389
----------------------------------- PR info ------------------------------------
Title      lib: respect terminal capabilities on styleText (#54389)
Author     Rafael Gonzaga <[email protected]> (@RafaelGSS)
Branch     RafaelGSS:support-tty-no-colors-styleText -> nodejs:main
Labels     util, author ready, needs-ci
Commits    8
 - lib: respect terminal capabilities on styleText
 - fixup! lib: respect terminal capabilities on styleText
 - fixup! fixup! lib: respect terminal capabilities on styleText
 - fixup! fixup! fixup! lib: respect terminal capabilities on styleText
 - fixup! fixup! lib: respect terminal capabilities on styleText
 - fixup! fixup! lib: respect terminal capabilities on styleText
 - fixup! lib: respect terminal capabilities on styleText
 - fixup! doc: added missing options
Committers 2
 - RafaelGSS <[email protected]>
 - GitHub <[email protected]>
PR-URL: https://github.com/nodejs/node/pull/54389
Fixes: https://github.com/nodejs/node/issues/54365
Reviewed-By: Moshe Atlow <[email protected]>
Reviewed-By: Claudio Wunder <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/54389
Fixes: https://github.com/nodejs/node/issues/54365
Reviewed-By: Moshe Atlow <[email protected]>
Reviewed-By: Claudio Wunder <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
--------------------------------------------------------------------------------
   ℹ  This PR was created on Wed, 14 Aug 2024 23:02:26 GMT
   ✔  Approvals: 3
   ✔  - Moshe Atlow (@MoLow) (TSC): https://github.com/nodejs/node/pull/54389#pullrequestreview-2241573413
   ✔  - Claudio Wunder (@ovflowd): https://github.com/nodejs/node/pull/54389#pullrequestreview-2258107034
   ✔  - Rich Trott (@Trott): https://github.com/nodejs/node/pull/54389#pullrequestreview-2266730509
   ✔  Last GitHub CI successful
   ℹ  Last Full PR CI on 2024-08-28T15:23:06Z: https://ci.nodejs.org/job/node-test-pull-request/61554/
- Querying data for job/node-test-pull-request/61554/
   ✔  Last Jenkins CI successful
--------------------------------------------------------------------------------
   ✔  No git cherry-pick in progress
   ✔  No git am in progress
   ✔  No git rebase in progress
--------------------------------------------------------------------------------
- Bringing origin/main up to date...
From https://github.com/nodejs/node
 * branch                  main       -> FETCH_HEAD
✔  origin/main is now up-to-date
- Downloading patch for 54389
From https://github.com/nodejs/node
 * branch                  refs/pull/54389/merge -> FETCH_HEAD
✔  Fetched commits as 4f14eb15454b..5efe9b82599c
--------------------------------------------------------------------------------
[main 55d1354111] lib: respect terminal capabilities on styleText
 Author: RafaelGSS <[email protected]>
 Date: Wed Aug 14 19:57:36 2024 -0300
 3 files changed, 67 insertions(+), 5 deletions(-)
[main 7ec91c26d9] fixup! lib: respect terminal capabilities on styleText
 Author: RafaelGSS <[email protected]>
 Date: Wed Aug 14 20:08:28 2024 -0300
 1 file changed, 1 insertion(+), 1 deletion(-)
[main 422171783b] fixup! fixup! lib: respect terminal capabilities on styleText
 Author: RafaelGSS <[email protected]>
 Date: Fri Aug 16 17:44:36 2024 -0300
 3 files changed, 48 insertions(+), 4 deletions(-)
[main ad5e175dd2] fixup! fixup! fixup! lib: respect terminal capabilities on styleText
 Author: RafaelGSS <[email protected]>
 Date: Tue Aug 20 10:41:16 2024 -0300
 1 file changed, 27 insertions(+), 23 deletions(-)
[main bd2ac50c92] fixup! fixup! lib: respect terminal capabilities on styleText
 Author: RafaelGSS <[email protected]>
 Date: Tue Aug 20 10:51:51 2024 -0300
 1 file changed, 1 insertion(+), 1 deletion(-)
[main 2287f02857] fixup! fixup! lib: respect terminal capabilities on styleText
 Author: RafaelGSS <[email protected]>
 Date: Tue Aug 20 13:10:50 2024 -0300
 3 files changed, 34 insertions(+), 11 deletions(-)
[main 523bf9bca5] fixup! lib: respect terminal capabilities on styleText
 Author: RafaelGSS <[email protected]>
 Date: Wed Aug 21 15:55:02 2024 -0300
 1 file changed, 1 insertion(+), 1 deletion(-)
[main e689cbf8d6] fixup! doc: added missing options
 Author: Claudio W <[email protected]>
 Date: Sat Aug 24 20:14:48 2024 +0200
 1 file changed, 1 insertion(+), 1 deletion(-)
   ✔  Patches applied
There are 8 commits in the PR. Attempting autorebase.
Rebasing (2/10)
Rebasing (3/10)
Rebasing (4/10)
Rebasing (5/10)
Rebasing (6/10)
Rebasing (7/10)
Rebasing (8/10)

Executing: git node land --amend --yes --------------------------------- New Message ---------------------------------- lib: respect terminal capabilities on styleText

This PR changes styleText API to respect terminal capabilities and environment variables such as NO_COLOR, NODE_DISABLE_COLORS, and FORCE_COLOR.

PR-URL: https://github.com/nodejs/node/pull/54389 Fixes: https://github.com/nodejs/node/issues/54365 Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Claudio Wunder <[email protected]> Reviewed-By: Rich Trott <[email protected]>

[detached HEAD e25254dd5f] lib: respect terminal capabilities on styleText Author: RafaelGSS <[email protected]> Date: Wed Aug 14 19:57:36 2024 -0300 4 files changed, 145 insertions(+), 12 deletions(-) Rebasing (9/10) Rebasing (10/10)

Executing: git node land --amend --yes --------------------------------- New Message ---------------------------------- fixup! doc: added missing options

PR-URL: https://github.com/nodejs/node/pull/54389 Fixes: https://github.com/nodejs/node/issues/54365 Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Claudio Wunder <[email protected]> Reviewed-By: Rich Trott <[email protected]>

[detached HEAD 5165048bb4] fixup! doc: added missing options Author: Claudio W <[email protected]> Date: Sat Aug 24 20:14:48 2024 +0200 1 file changed, 1 insertion(+), 1 deletion(-)

Successfully rebased and updated refs/heads/main.

ℹ Add commit-queue-squash label to land the PR as one commit, or commit-queue-rebase to land as separate commits.

https://github.com/nodejs/node/actions/runs/10601594749

nodejs-github-bot avatar Aug 28 '24 17:08 nodejs-github-bot

Landed in 4a0ec20a35aff521c3a08e42b3905012a6566c00

nodejs-github-bot avatar Aug 28 '24 18:08 nodejs-github-bot