4
4
5
5
require ( '../common' ) ;
6
6
const stream = require ( 'stream' ) ;
7
+ const { describe, test } = require ( 'node:test' ) ;
7
8
const REPL = require ( 'internal/repl' ) ;
8
9
const assert = require ( 'assert' ) ;
9
10
const inspect = require ( 'util' ) . inspect ;
@@ -18,13 +19,21 @@ const tests = [
18
19
env : { NODE_DISABLE_COLORS : '1' } ,
19
20
expected : { terminal : true , useColors : false }
20
21
} ,
22
+ {
23
+ env : { NODE_DISABLE_COLORS : '1' , FORCE_COLOR : '1' } ,
24
+ expected : { terminal : true , useColors : true }
25
+ } ,
21
26
{
22
27
env : { NODE_NO_READLINE : '1' } ,
23
28
expected : { terminal : false , useColors : false }
24
29
} ,
25
30
{
26
31
env : { TERM : 'dumb' } ,
27
- expected : { terminal : true , useColors : false }
32
+ expected : { terminal : true , useColors : true }
33
+ } ,
34
+ {
35
+ env : { TERM : 'dumb' , FORCE_COLOR : '1' } ,
36
+ expected : { terminal : true , useColors : true }
28
37
} ,
29
38
{
30
39
env : { NODE_NO_READLINE : '1' , NODE_DISABLE_COLORS : '1' } ,
@@ -56,20 +65,25 @@ function run(test) {
56
65
57
66
Object . assign ( process . env , env ) ;
58
67
59
- REPL . createInternalRepl ( process . env , opts , function ( err , repl ) {
60
- assert . ifError ( err ) ;
68
+ return new Promise ( ( resolve ) => {
69
+ REPL . createInternalRepl ( process . env , opts , function ( err , repl ) {
70
+ assert . ifError ( err ) ;
61
71
62
- assert . strictEqual ( repl . terminal , expected . terminal ,
63
- `Expected ${ inspect ( expected ) } with ${ inspect ( env ) } ` ) ;
64
- assert . strictEqual ( repl . useColors , expected . useColors ,
65
- `Expected ${ inspect ( expected ) } with ${ inspect ( env ) } ` ) ;
66
- assert . strictEqual ( repl . replMode , expected . replMode || REPL_MODE_SLOPPY ,
67
- `Expected ${ inspect ( expected ) } with ${ inspect ( env ) } ` ) ;
68
- for ( const key of Object . keys ( env ) ) {
69
- delete process . env [ key ] ;
70
- }
71
- repl . close ( ) ;
72
+ assert . strictEqual ( repl . terminal , expected . terminal ,
73
+ `Expected ${ inspect ( expected ) } with ${ inspect ( env ) } ` ) ;
74
+ assert . strictEqual ( repl . useColors , expected . useColors ,
75
+ `Expected ${ inspect ( expected ) } with ${ inspect ( env ) } ` ) ;
76
+ assert . strictEqual ( repl . replMode , expected . replMode || REPL_MODE_SLOPPY ,
77
+ `Expected ${ inspect ( expected ) } with ${ inspect ( env ) } ` ) ;
78
+ for ( const key of Object . keys ( env ) ) {
79
+ delete process . env [ key ] ;
80
+ }
81
+ repl . close ( ) ;
82
+ resolve ( ) ;
83
+ } ) ;
72
84
} ) ;
73
85
}
74
86
75
- tests . forEach ( run ) ;
87
+ describe ( 'REPL environment variables' , { concurrency : 1 } , ( ) => {
88
+ tests . forEach ( ( testCase ) => test ( inspect ( testCase . env ) , ( ) => run ( testCase ) ) ) ;
89
+ } ) ;
0 commit comments