-
-
Notifications
You must be signed in to change notification settings - Fork 32k
lib: support dumb terminals #26261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lib: support dumb terminals #26261
Changes from all commits
1c0ba10
1b7434d
6aa691d
826bab4
4113cfe
1468212
26fcf31
03994a0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -501,7 +501,9 @@ function REPLServer(prompt, | |
self.writer = options.writer || exports.writer; | ||
|
||
if (options.useColors === undefined) { | ||
options.useColors = self.terminal; | ||
options.useColors = self.terminal && ( | ||
typeof self.outputStream.getColorDepth === 'function' ? | ||
self.outputStream.getColorDepth() > 2 : true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch while it won't have any actual impact (the return values are either There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I got that check from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @wlodzislav I think it’s okay to leave that for a separate PR, but here it would be good to replace it with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I fixed this while landing. |
||
} | ||
self.useColors = !!options.useColors; | ||
|
||
|
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' }); |
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
'use strict'; | ||
require('../common'); | ||
|
||
process.env.TERM = 'dumb'; | ||
|
||
const readline = require('readline'); | ||
|
||
const rl = readline.createInterface({ | ||
input: process.stdin, | ||
output: process.stdout | ||
}); | ||
|
||
rl.write('text'); | ||
rl.write(null, { ctrl: true, name: 'u' }); | ||
rl.write(null, { name: 'return' }); | ||
rl.write('text'); | ||
rl.write(null, { name: 'backspace' }); | ||
rl.write(null, { name: 'escape' }); | ||
rl.write(null, { name: 'enter' }); | ||
rl.write('text'); | ||
rl.write(null, { ctrl: true, name: 'c' }); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
text | ||
text | ||
text |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
'use strict'; | ||
require('../common'); | ||
|
||
process.env.TERM = 'dumb'; | ||
|
||
const repl = require('repl'); | ||
|
||
repl.start('> '); | ||
process.stdin.push('console.log("foo")\n'); | ||
process.stdin.push('1 + 2\n'); | ||
process.stdin.push('"str"\n'); | ||
process.stdin.push('console.dir({ a: 1 })\n'); | ||
process.stdin.push('{ a: 1 }\n'); | ||
process.stdin.push('\n'); | ||
process.stdin.push('.exit\n'); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
> console.log("foo") | ||
foo | ||
undefined | ||
> 1 + 2 | ||
3 | ||
> "str" | ||
'str' | ||
> console.dir({ a: 1 }) | ||
{ a: 1 } | ||
undefined | ||
> { a: 1 } | ||
{ a: 1 } | ||
> | ||
> .exit |
Uh oh!
There was an error while loading. Please reload this page.