@@ -5,7 +5,7 @@ const assertHasColorsArguments = count => {
5
5
tty . WriteStream . prototype . hasColors ( count ) ;
6
6
} ;
7
7
8
- const makeHasColors = colorDepth => ( count = 16 , env = undefined ) => {
8
+ const makeHasColors = colorDepth => ( count = 16 , env ) => { // eslint-disable-line default-param-last
9
9
// `count` is optional too, so make sure it's not an env object.
10
10
if ( env === undefined && typeof count === 'object' && count !== null ) {
11
11
count = 16 ;
@@ -15,7 +15,7 @@ const makeHasColors = colorDepth => (count = 16, env = undefined) => {
15
15
return count <= 2 ** colorDepth ;
16
16
} ;
17
17
18
- const simulateTTY = ( stream , colorDepth , hasColors ) => {
18
+ const simulateTTY = ( stream , colorDepth ) => {
19
19
stream . isTTY = true ;
20
20
stream . columns = 80 ;
21
21
stream . rows = 24 ;
@@ -24,9 +24,10 @@ const simulateTTY = (stream, colorDepth, hasColors) => {
24
24
stream . getColorDepth = ( ) => colorDepth ;
25
25
}
26
26
27
- if ( hasColors ) {
28
- stream . hasColors = makeHasColors ( colorDepth ) ;
29
- }
27
+ stream . hasColors = makeHasColors ( colorDepth ) ;
28
+ stream . clearLine = tty . WriteStream . prototype . clearLine ;
29
+ stream . cursorTo = tty . WriteStream . prototype . cursorTo ;
30
+ stream . moveCursor = tty . WriteStream . prototype . moveCursor ;
30
31
} ;
31
32
32
33
// The execCli helper spawns tests in a child process. This means that stdout is
@@ -36,8 +37,7 @@ if (process.env.AVA_SIMULATE_TTY) {
36
37
const colorDepth = process . env . AVA_TTY_COLOR_DEPTH ?
37
38
Number . parseInt ( process . env . AVA_TTY_COLOR_DEPTH , 10 ) :
38
39
undefined ;
39
- const hasColors = process . env . AVA_TTY_HAS_COLORS !== undefined ;
40
40
41
- simulateTTY ( process . stderr , colorDepth , hasColors ) ;
42
- simulateTTY ( process . stdout , colorDepth , hasColors ) ;
41
+ simulateTTY ( process . stderr , colorDepth ) ;
42
+ simulateTTY ( process . stdout , colorDepth ) ;
43
43
}
0 commit comments