mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
console: don't use ANSI escape codes when TERM=dumb
PR-URL: https://github.com/nodejs/node/pull/26261 Fixes: https://github.com/nodejs/node/issues/26187 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
This commit is contained in:
parent
5f032a7a26
commit
99523758dc
@ -346,7 +346,7 @@ const consoleMethods = {
|
||||
clear() {
|
||||
// It only makes sense to clear if _stdout is a TTY.
|
||||
// Otherwise, do nothing.
|
||||
if (this._stdout.isTTY) {
|
||||
if (this._stdout.isTTY && process.env.TERM !== 'dumb') {
|
||||
// The require is here intentionally to avoid readline being
|
||||
// required too early when console is first loaded.
|
||||
const { cursorTo, clearScreenDown } = require('readline');
|
||||
|
9
test/pseudo-tty/console-dumb-tty.js
Normal file
9
test/pseudo-tty/console-dumb-tty.js
Normal file
@ -0,0 +1,9 @@
|
||||
'use strict';
|
||||
require('../common');
|
||||
|
||||
process.env.TERM = 'dumb';
|
||||
|
||||
console.log({ foo: 'bar' });
|
||||
console.dir({ foo: 'bar' });
|
||||
console.log('%s q', 'string');
|
||||
console.log('%o with object format param', { foo: 'bar' });
|
4
test/pseudo-tty/console-dumb-tty.out
Normal file
4
test/pseudo-tty/console-dumb-tty.out
Normal file
@ -0,0 +1,4 @@
|
||||
{ foo: 'bar' }
|
||||
{ foo: 'bar' }
|
||||
string q
|
||||
{ foo: 'bar' } with object format param
|
Loading…
Reference in New Issue
Block a user