mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
repl: fix NO_COLORS env var is ignored
PR-URL: https://github.com/nodejs/node/pull/51568 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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' },
|
||||
@@ -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' },
|
||||
@@ -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 }
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
@@ -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);
|
||||
assert.strictEqual(r1.useGlobal, false);
|
||||
assert.strictEqual(r1.ignoreUndefined, false);
|
||||
assert.strictEqual(r1.replMode, repl.REPL_MODE_SLOPPY);
|
||||
|
||||
Reference in New Issue
Block a user