0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-30 23:43:09 +01:00
nodejs/test/pseudo-tty/readline-dumb-tty.js
Vladislav Kaminsky d3a62fe7fc
readline: support TERM=dumb
When TERM=dumb and .isTTY=true don't use ANSI escape codes
and ignore all keys, except 'escape', 'return' and 'ctrl-c'.

PR-URL: https://github.com/nodejs/node/pull/26261
Fixes: https://github.com/nodejs/node/issues/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>
2019-03-21 23:33:55 +01:00

22 lines
482 B
JavaScript

'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' });