Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
console: don't use ANSI escape codes when TERM=dumb
Fixes: #26187
  • Loading branch information
wlodzislav committed Mar 5, 2019
commit 1c0ba1061e5a6eb9abf817a64550fe0a501c04d7
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