diff options
author | Ruben Bridgewater <ruben@bridgewater.de> | 2019-02-22 19:15:07 +0100 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2019-03-03 23:31:44 +0100 |
commit | f871c80a6d4a78438d6e19ec9ef812d53fc75c92 (patch) | |
tree | e975fb8b2af8a4c4d95d564e0974cd9fb63d8abb /test/pseudo-tty | |
parent | 7f2d2cdc0cb45b8c97abf152b5cce6ec43aaaf79 (diff) | |
download | android-node-v8-f871c80a6d4a78438d6e19ec9ef812d53fc75c92.tar.gz android-node-v8-f871c80a6d4a78438d6e19ec9ef812d53fc75c92.tar.bz2 android-node-v8-f871c80a6d4a78438d6e19ec9ef812d53fc75c92.zip |
tty: improve color detection
1) Using `process.env.TERM = 'dumb'` should never return any colors.
2) `process.env.TERM = 'terminator'` supports 24 bit colors.
3) Add support for `process.env.TERM = 'rxvt-unicode-24bit'`
4) `Hyper` does not support true colors anymore. It should fall back
to the xterm settings in regular cases.
5) `process.env.COLORTERM = 'truecolor'` should return 24 bit colors.
PR-URL: https://github.com/nodejs/node/pull/26264
Refs: https://github.com/nodejs/node/pull/26261
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test/pseudo-tty')
-rw-r--r-- | test/pseudo-tty/test-tty-get-color-depth.js | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/test/pseudo-tty/test-tty-get-color-depth.js b/test/pseudo-tty/test-tty-get-color-depth.js index d4062f5fdb..14151ec3fb 100644 --- a/test/pseudo-tty/test-tty-get-color-depth.js +++ b/test/pseudo-tty/test-tty-get-color-depth.js @@ -3,6 +3,7 @@ const common = require('../common'); const assert = require('assert').strict; const { WriteStream } = require('tty'); +const { inspect } = require('util'); const fd = common.getTTYfd(); const writeStream = new WriteStream(fd); @@ -16,6 +17,8 @@ const writeStream = new WriteStream(fd); // Check different environment variables. [ [{ COLORTERM: '1' }, 4], + [{ COLORTERM: 'truecolor' }, 24], + [{ COLORTERM: '24bit' }, 24], [{ TMUX: '1' }, 8], [{ CI: '1' }, 1], [{ CI: '1', TRAVIS: '1' }, 8], @@ -29,7 +32,7 @@ const writeStream = new WriteStream(fd); [{ TERM_PROGRAM: 'iTerm.app', TERM_PROGRAM_VERSION: '3.0' }, 24], [{ TERM_PROGRAM: 'iTerm.app', TERM_PROGRAM_VERSION: '2.0' }, 8], [{ TERM_PROGRAM: 'HyperTerm' }, 24], - [{ TERM_PROGRAM: 'Hyper' }, 24], + [{ TERM_PROGRAM: 'Hyper' }, 1], [{ TERM_PROGRAM: 'MacTerm' }, 24], [{ TERM_PROGRAM: 'Apple_Terminal' }, 8], [{ TERM: 'xterm-256' }, 8], @@ -40,13 +43,16 @@ const writeStream = new WriteStream(fd); [{ TERM: 'fail' }, 1], [{ NODE_DISABLE_COLORS: '1' }, 1], [{ TERM: 'dumb' }, 1], - [{ TERM: 'dumb', COLORTERM: '1' }, 4], + [{ TERM: 'dumb', COLORTERM: '1' }, 1], + [{ TERM: 'terminator' }, 24], + [{ TERM: 'console' }, 4] ].forEach(([env, depth], i) => { const actual = writeStream.getColorDepth(env); assert.strictEqual( actual, depth, - `i: ${i}, expected: ${depth}, actual: ${actual}, env: ${env}` + `i: ${i}, expected: ${depth}, ` + + `actual: ${actual}, env: ${inspect(env)}` ); }); |