Skip to content

Conversation

@jakebailey
Copy link
Member

Fixes #2540

picocolors, chalk, Node, etc, all support this.

Strada doesn't, but it seems to matter for people trying to use tsgo, so, I think it's worth doing. And probably sticking in Strada if we want.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Implements support for the FORCE_COLOR environment variable in the tsc CLI so that colored output can be forced even when stdout is not a TTY, while still honoring NO_COLOR to disable colors.

Changes:

  • Updated defaultIsPretty to consider NO_COLOR and FORCE_COLOR before falling back to TTY detection.
  • Extended TestTscCommandline with scenarios that cover FORCE_COLOR alone and NO_COLOR plus FORCE_COLOR.
  • Added new command-line baselines to validate colored vs non-colored help output under these environment configurations.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
internal/execute/tsc/diagnostics.go Adjusts defaultIsPretty so NO_COLOR disables colors, FORCE_COLOR forces colors regardless of TTY, and TTY is used only as a fallback.
internal/execute/tsctests/tsc_test.go Adds two new command-line test scenarios exercising FORCE_COLOR and the precedence of NO_COLOR over FORCE_COLOR.
testdata/baselines/reference/tsc/commandLine/adds-color-when-FORCE_COLOR-is-set.js Baseline showing ANSI-colored help output when FORCE_COLOR is set.
testdata/baselines/reference/tsc/commandLine/does-not-add-color-when-NO_COLOR-is-set-even-if-FORCE_COLOR-is-set.js Baseline confirming uncolored help output when NO_COLOR is set, even if FORCE_COLOR is also set.

if sys.GetEnvironmentVariable("NO_COLOR") != "" {
return false
}
if sys.GetEnvironmentVariable("FORCE_COLOR") != "" {
Copy link
Member

Choose a reason for hiding this comment

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

It's weird that we just look for any content (e.g. someone could write FALSE), but I don't know how other tools deal with this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

@DanielRosenwasser DanielRosenwasser left a comment

Choose a reason for hiding this comment

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

If all tools deal with non-empty strings in this way, seems good.

@jakebailey jakebailey added this pull request to the merge queue Jan 28, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 28, 2026
@jakebailey jakebailey added this pull request to the merge queue Jan 28, 2026
Merged via the queue into main with commit 01cc2f9 Jan 28, 2026
28 checks passed
@jakebailey jakebailey deleted the jabaile/force-colort branch January 28, 2026 01:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Should handle FORCE_COLOR environment variable

4 participants