From b9566531bb981b3da8e8bf431853da759821a6d9 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Tue, 17 Dec 2024 23:21:06 +0100 Subject: [PATCH] Revert "Fix: CLI flags and FORCE_COLOR should precede other color support checks (#154)" This reverts commit edc5d7dd0e9b8266c2aa95b58181f9a71826fb85. --- index.js | 6 +++--- test.js | 16 ---------------- 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/index.js b/index.js index 6c6a433..85dabbb 100644 --- a/index.js +++ b/index.js @@ -77,8 +77,8 @@ function _supportsColor(haveStream, {streamIsTTY, sniffFlags = true} = {}) { const forceColor = sniffFlags ? flagForceColor : noFlagForceColor; - if (forceColor !== undefined) { - return forceColor; + if (forceColor === 0) { + return 0; } if (sniffFlags) { @@ -103,7 +103,7 @@ function _supportsColor(haveStream, {streamIsTTY, sniffFlags = true} = {}) { return 0; } - const min = 0; + const min = forceColor || 0; if (env.TERM === 'dumb') { return min; diff --git a/test.js b/test.js index 84874b7..4de3180 100644 --- a/test.js +++ b/test.js @@ -52,22 +52,6 @@ test('return true if `FORCE_COLOR` is in env, but honor 256 #2', async t => { t.is(result.stdout.level, 2); }); -test('CLI color flags precede other color support checks', async t => { - process.env.COLORTERM = 'truecolor'; - process.argv = ['--color=256']; - const result = await importMain(); - t.truthy(result.stdout); - t.is(result.stdout.level, 2); -}); - -test('`FORCE_COLOR` environment variable precedes other color support checks', async t => { - process.env.COLORTERM = 'truecolor'; - process.env.FORCE_COLOR = '2'; - const result = await importMain(); - t.truthy(result.stdout); - t.is(result.stdout.level, 2); -}); - test('return false if `FORCE_COLOR` is in env and is 0', async t => { process.env.FORCE_COLOR = '0'; const result = await importMain();