GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — lib: support `FORCE_COLOR` for non TTY streams by MoLow · Pull Request #48034 · nodejs/node

Conversation

@MoLow

@MoLow MoLow commented May 16, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

The current behavior of FORCE_COLOR is to take effect when stdout/stderr are TTY's

according to the documentation:

The FORCE_COLOR environment variable is used to enable ANSI colorized output.

this PR moves the check for the value of FORCE_COLOR before testing isTTY - and extracts the logic to a central utility.

Refs: #31409 (comment)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bricss and omril1 reacted with thumbs up emoji
All reactions
  • 👍 2 reactions
@nodejs-github-bot

nodejs-github-bot commented May 16, 2023

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/test_runner
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot nodejs-github-bot added lib / src Issues and PRs involving general changes in the lib/ or src/ directories. needs-ci PRs that need a full CI run. labels May 16, 2023
MoLow
MoLow commented May 16, 2023
View reviewed changes
Comment thread test/parallel/test-repl-envvars.js Outdated

@MoLow MoLow May 16, 2023

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests did not play well when running in parallel. used node:test to run them sequentially

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@MoLow
MoLow force-pushed the force-colors branch from 847a6d9 to 25bab5c Compare May 16, 2023 12:43
@MoLow

MoLow commented May 16, 2023

Copy link
Copy Markdown
Member Author

/CC @nodejs/util @nodejs/console

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

anonrig
anonrig reviewed May 16, 2023
View reviewed changes
Comment thread lib/internal/util/colors.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/internal/util/colors.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/internal/util/colors.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/internal/util/colors.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@MoLow
MoLow force-pushed the force-colors branch from 25bab5c to 2ceb670 Compare May 16, 2023 14:44
ljharb
ljharb approved these changes May 16, 2023
View reviewed changes
Comment thread lib/repl.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@MoLow
lib: support FORCE_COLOR for non TTY streams
cb4fc99
@MoLow
MoLow force-pushed the force-colors branch from 2ceb670 to cb4fc99 Compare May 16, 2023 19:37
@MoLow
MoLow requested a review from anonrig May 17, 2023 05:31
anonrig
anonrig approved these changes May 17, 2023
View reviewed changes
@MoLow
MoLow requested review from aduh95, anonrig, benjamingr and cjihrig May 17, 2023 14:43
benjamingr
benjamingr approved these changes May 17, 2023
View reviewed changes
@MoLow MoLow added author ready PRs with CI started, the required approvals, and no outstanding review comments. request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. labels May 17, 2023
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label May 17, 2023
@nodejs-github-bot

nodejs-github-bot commented May 17, 2023

Copy link
Copy Markdown
Collaborator

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

aduh95
aduh95 reviewed May 17, 2023
View reviewed changes
Comment thread test/fixtures/errors/force_colors.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@MoLow @aduh95
Update test/fixtures/errors/force_colors.js
4c6d273
Co-authored-by: Antoine du Hamel <[email protected]>
@MoLow MoLow added the commit-queue-squash PRs the Commit Queue should land as one squashed commit. label May 17, 2023
@MoLow
fix
cbef320
@MoLow MoLow added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label May 17, 2023
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label May 17, 2023
@nodejs-github-bot

nodejs-github-bot commented May 17, 2023

Copy link
Copy Markdown
Collaborator

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@MoLow
fix
1deee84
targos pushed a commit that referenced this pull request May 30, 2023
@MoLow @targos
lib: support FORCE_COLOR for non TTY streams
a90010a
PR-URL: #48034
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
@targos targos mentioned this pull request Jun 4, 2023
v20.3.0 release proposal #48332
Merged
@danielleadams danielleadams added the backport-requested-v18.x label Jul 5, 2023
@danielleadams

danielleadams commented Jul 5, 2023

Copy link
Copy Markdown
Contributor

This broke tests when pulling into v18, so it needs a backport.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@MoLow

MoLow commented Jul 6, 2023

Copy link
Copy Markdown
Member Author

@danielleadams It seems v18.x-staging is missing some other commits this PR depends on (b6738c1, 03db049) is that delibirate?
anyway I will create a backport PR for all the three

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@MoLow

MoLow commented Jul 6, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

@danielleadams cherry-picking this sequence of commits lands clearly with no conflicts and all tests pass, so I assume the staging branch is missing many many more parts

334bb17
d51541b
d1eaded
2e8f8eb
6d06586
102540a
af8ed02
7ec93fb
57508fb
b6738c1
46a3cff
d3b0a2a
9e5e2f1
03db049
05693ac

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@danielleadams

danielleadams commented Jul 6, 2023

Copy link
Copy Markdown
Contributor

Talked to @MoLow offline, but staging branch is ready for backport now.

MoLow reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

MoLow added a commit to MoLow/node that referenced this pull request Jul 6, 2023
@MoLow
lib: support FORCE_COLOR for non TTY streams
d7d3c0a
PR-URL: nodejs#48034
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
@MoLow MoLow mentioned this pull request Jul 6, 2023
[v18.x backport] lib: support FORCE_COLOR for non TTY streams #48682
Closed
@MoLow MoLow added backport-open-v18.x and removed backport-requested-v18.x labels Jul 6, 2023
@MoLow MoLow mentioned this pull request Jul 9, 2023
[v18.x backport] test_runner: align stdout and std error with and without --test #48684
Closed
MoLow added a commit to MoLow/node that referenced this pull request Jul 9, 2023
@MoLow
lib: support FORCE_COLOR for non TTY streams
b23dcb9
PR-URL: nodejs#48034
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
danielleadams pushed a commit that referenced this pull request Jul 12, 2023
@MoLow @danielleadams
lib: support FORCE_COLOR for non TTY streams
c46b31f
PR-URL: #48034
Backport-PR-URL: #48684
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
@danielleadams danielleadams added backported-to-v18.x and removed backport-open-v18.x labels Jul 12, 2023
@danielleadams danielleadams mentioned this pull request Jul 12, 2023
v18.17.0 release proposal #48694
Merged
@aweebit aweebit mentioned this pull request Aug 7, 2023
[Bug]: FORCE_COLOR set internally leaks through to tests on Windows after upgrade to Node.js v18.17.0 jestjs/jest#14391
Closed
@trentm trentm mentioned this pull request Nov 3, 2023
chore: use npm workspaces and a package-lock.json open-telemetry/opentelemetry-js-contrib#1771
Merged
@addaleax

addaleax commented Jan 22, 2024

Copy link
Copy Markdown
Member

@MoLow Small heads up, this seems to have broken NO_COLOR support for the REPL (i.e. NO_COLOR=1 node now uses color mode when previously it didn't)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@MoLow

MoLow commented Jan 23, 2024

Copy link
Copy Markdown
Member Author

@addaleax I am not able to reproduce this:
image
what specifically are you running inside the repl?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@addaleax

addaleax commented Jan 23, 2024

Copy link
Copy Markdown
Member

@MoLow Yeah, console.log() works perfectly (its doesn't inherit colorization from the REPL), but if you enter e.g. just 111 as the input instead of console.log(111) you'll see that the output is colorized in both cases with 20.10.0, as opposed to e.g. 20.2.0

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@MoLow MoLow mentioned this pull request Jan 26, 2024
repl: fix NO_COLORS env var is ignored #51568
Merged
@dgozman dgozman mentioned this pull request Mar 25, 2024
feat(test runner): do not mock tty in the worker process microsoft/playwright#30107
Merged
dgozman added a commit to microsoft/playwright that referenced this pull request Mar 25, 2024
@dgozman
feat(test runner): do not mock tty in the worker process (#30107)
911d8ef
This was historically done to make `console.log()` have colors. However,
this makes any other code that checks `process.stdout.isTTY` incorrectly
assume real TTY support.

Node18 and Node20 now respect `FORCE_COLOR=1` in console, so our default
behavior of forcing colors in the worker process just works out of the
box. See nodejs/node#48034.
@richardlau richardlau mentioned this pull request Jan 7, 2025
NO_COLOR not an alias for NODE_DISABLE_COLORS in v18 #56509
Closed
@coderabbitai coderabbitai Bot mentioned this pull request Aug 21, 2026
feat(dev): interactive terminal ui for the dev server nuxt/cli#1463
Merged
@robobun robobun mentioned this pull request Oct 23, 2026
console.Console: decide colors from FORCE_COLOR as Node does oven-sh/bun#46590
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@aduh95 aduh95 aduh95 left review comments
@ljharb ljharb ljharb approved these changes
@benjamingr benjamingr benjamingr approved these changes
@anonrig anonrig anonrig approved these changes
@cjihrig cjihrig Awaiting requested review from cjihrig

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. commit-queue-squash PRs the Commit Queue should land as one squashed commit. lib / src Issues and PRs involving general changes in the lib/ or src/ directories. needs-ci PRs that need a full CI run.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

8 participants

@MoLow @nodejs-github-bot @danielleadams @addaleax @ljharb @benjamingr @anonrig @aduh95
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.