fix: respect FORCE_COLOR env var over auto-detection

The FORCE_COLOR environment variable was being overridden by other
environment variables like COLORTERM, TERM, etc. This fix ensures
that when FORCE_COLOR is explicitly set, its value takes precedence
over automatic color support detection.

Fixes #624
This commit is contained in:
Zovo Bot 2026-03-03 13:45:01 +07:00
parent aa06bb5ac3
commit 38068f6296

View file

@ -93,6 +93,12 @@ function _supportsColor(haveStream, {streamIsTTY, sniffFlags = true} = {}) {
const min = forceColor || 0; const min = forceColor || 0;
// If forceColor was explicitly set (via FORCE_COLOR env or --color flag),
// respect it and don't override with auto-detection
if (forceColor !== undefined) {
return min;
}
if (env.TERM === 'dumb') { if (env.TERM === 'dumb') {
return min; return min;
} }