Skip to content

Commit

Permalink
Revert "Fix: CLI flags and FORCE_COLOR should precede other color sup…
Browse files Browse the repository at this point in the history
…port checks (#154)"

This reverts commit edc5d7d.
  • Loading branch information
sindresorhus committed Dec 17, 2024
1 parent c214314 commit b956653
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 19 deletions.
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand Down
16 changes: 0 additions & 16 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit b956653

Please sign in to comment.