Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$FORCE_COLOR works only as either level 0 or 3 #624

Open
m15a opened this issue Feb 10, 2024 · 1 comment
Open

$FORCE_COLOR works only as either level 0 or 3 #624

m15a opened this issue Feb 10, 2024 · 1 comment

Comments

@m15a
Copy link

m15a commented Feb 10, 2024

I tried to override the level of color support using $FORCE_COLOR environment variable, but I got

> cat test.mjs
import { supportsColor } from 'chalk';
console.log("FORCE_COLOR:", process.env.FORCE_COLOR, "\tsupportsColor:", supportsColor);

> for i in 0 1 2 3; env FORCE_COLOR=$i node test.mjs; end
FORCE_COLOR: 0 	supportsColor: false
FORCE_COLOR: 1 	supportsColor: { level: 3, hasBasic: true, has256: true, has16m: true }
FORCE_COLOR: 2 	supportsColor: { level: 3, hasBasic: true, has256: true, has16m: true }
FORCE_COLOR: 3 	supportsColor: { level: 3, hasBasic: true, has256: true, has16m: true }

Chalk version: 5.3.0
Node version: 20.10.0

Note that my terminal is Alacritty and it supports truecolor, so the default color support level should be 3 in my environment.

@m15a
Copy link
Author

m15a commented Feb 12, 2024

Oh I see. If $COLORTERM=truecolor is set, even if $FORCE_COLOR is less than 3, supportsColor happens to be set to 3.

> set --global --export COLORTERM truecolor
> for i in 0 1 2 3; env FORCE_COLOR=$i node test.mjs; end
FORCE_COLOR: 0 	supportsColor: false
FORCE_COLOR: 1 	supportsColor: { level: 3, hasBasic: true, has256: true, has16m: true }
FORCE_COLOR: 2 	supportsColor: { level: 3, hasBasic: true, has256: true, has16m: true }
FORCE_COLOR: 3 	supportsColor: { level: 3, hasBasic: true, has256: true, has16m: true }

> set --erase COLORTERM
> for i in 0 1 2 3; env FORCE_COLOR=$i node test.mjs; end
FORCE_COLOR: 0 	supportsColor: false
FORCE_COLOR: 1 	supportsColor: { level: 1, hasBasic: true, has256: false, has16m: false }
FORCE_COLOR: 2 	supportsColor: { level: 2, hasBasic: true, has256: true, has16m: false }
FORCE_COLOR: 3 	supportsColor: { level: 3, hasBasic: true, has256: true, has16m: true }

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

No branches or pull requests

1 participant