Skip to content

Commit

Permalink
console: don't use ANSI escape codes when TERM=dumb
Browse files Browse the repository at this point in the history
PR-URL: #26261
Fixes: #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>
  • Loading branch information
wlodzislav authored and BridgeAR committed Mar 21, 2019
1 parent 5f032a7 commit 9952375
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/internal/console/constructor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
9 changes: 9 additions & 0 deletions test/pseudo-tty/console-dumb-tty.js
Original file line number Diff line number Diff line change
@@ -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 changes: 4 additions & 0 deletions test/pseudo-tty/console-dumb-tty.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{ foo: 'bar' }
{ foo: 'bar' }
string q
{ foo: 'bar' } with object format param

0 comments on commit 9952375

Please sign in to comment.