console: don't use ANSI escape codes when TERM=dumb · nodejs/node@9952375 (original) (raw)

3 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -346,7 +346,7 @@ const consoleMethods = {
346 346 clear() {
347 347 // It only makes sense to clear if _stdout is a TTY.
348 348 // Otherwise, do nothing.
349 -if (this._stdout.isTTY) {
349 +if (this._stdout.isTTY && process.env.TERM !== 'dumb') {
350 350 // The require is here intentionally to avoid readline being
351 351 // required too early when console is first loaded.
352 352 const { cursorTo, clearScreenDown } = require('readline');
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
1 +'use strict';
2 +require('../common');
3 +
4 +process.env.TERM = 'dumb';
5 +
6 +console.log({ foo: 'bar' });
7 +console.dir({ foo: 'bar' });
8 +console.log('%s q', 'string');
9 +console.log('%o with object format param', { foo: 'bar' });
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
1 +{ foo: 'bar' }
2 +{ foo: 'bar' }
3 +string q
4 +{ foo: 'bar' } with object format param