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

repl: fix NO_COLORS env var is ignored #51568

Merged
merged 1 commit into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ function REPLServer(prompt,

if (options.terminal && options.useColors === undefined) {
// If possible, check if stdout supports colors or not.
options.useColors = shouldColorize(options.output) || process.env.NODE_DISABLE_COLORS === undefined;
options.useColors = shouldColorize(options.output);
}

// TODO(devsnek): Add a test case for custom eval functions.
Expand Down
10 changes: 5 additions & 5 deletions test/parallel/test-repl-envvars.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const { REPL_MODE_SLOPPY, REPL_MODE_STRICT } = require('repl');
const tests = [
{
env: {},
expected: { terminal: true, useColors: true }
expected: { terminal: true, useColors: false }
},
{
env: { NODE_DISABLE_COLORS: '1' },
Expand All @@ -29,7 +29,7 @@ const tests = [
},
{
env: { TERM: 'dumb' },
expected: { terminal: true, useColors: true }
expected: { terminal: true, useColors: false }
},
{
env: { TERM: 'dumb', FORCE_COLOR: '1' },
Expand All @@ -41,15 +41,15 @@ const tests = [
},
{
env: { NODE_NO_READLINE: '0' },
expected: { terminal: true, useColors: true }
expected: { terminal: true, useColors: false }
},
{
env: { NODE_REPL_MODE: 'sloppy' },
expected: { terminal: true, useColors: true, replMode: REPL_MODE_SLOPPY }
expected: { terminal: true, useColors: false, replMode: REPL_MODE_SLOPPY }
},
{
env: { NODE_REPL_MODE: 'strict' },
expected: { terminal: true, useColors: true, replMode: REPL_MODE_STRICT }
expected: { terminal: true, useColors: false, replMode: REPL_MODE_STRICT }
},
];

Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-repl-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ assert.strictEqual(r1.output, stream);
assert.strictEqual(r1.input, r1.inputStream);
assert.strictEqual(r1.output, r1.outputStream);
assert.strictEqual(r1.terminal, true);
assert.strictEqual(r1.useColors, r1.terminal);
assert.strictEqual(r1.useColors, false);
BridgeAR marked this conversation as resolved.
Show resolved Hide resolved
assert.strictEqual(r1.useGlobal, false);
assert.strictEqual(r1.ignoreUndefined, false);
assert.strictEqual(r1.replMode, repl.REPL_MODE_SLOPPY);
Expand Down
Loading