@@ -5,6 +5,23 @@ import execa from '..';
5
5
6
6
process . env . PATH = path . join ( __dirname , 'fixtures' ) + path . delimiter + process . env . PATH ;
7
7
8
+ async function inspectMacro ( t , input ) {
9
+ const originalArgv = process . execArgv ;
10
+ process . execArgv = [ input , '-e' ] ;
11
+ try {
12
+ const subprocess = execa . node ( 'console.log("foo")' , {
13
+ reject : false
14
+ } ) ;
15
+
16
+ const { stdout, stderr} = await subprocess ;
17
+
18
+ t . is ( stdout , 'foo' ) ;
19
+ t . is ( stderr , '' ) ;
20
+ } finally {
21
+ process . execArgv = originalArgv ;
22
+ }
23
+ }
24
+
8
25
test ( 'node()' , async t => {
9
26
const { exitCode} = await execa . node ( 'test/fixtures/noop' ) ;
10
27
t . is ( exitCode , 0 ) ;
@@ -37,6 +54,43 @@ test('node pass on nodeOptions', async t => {
37
54
t . is ( stdout , 'foo' ) ;
38
55
} ) ;
39
56
57
+ test . serial (
58
+ 'node removes --inspect from nodeOptions when defined by parent process' ,
59
+ inspectMacro ,
60
+ '--inspect'
61
+ ) ;
62
+
63
+ test . serial (
64
+ 'node removes --inspect=9222 from nodeOptions when defined by parent process' ,
65
+ inspectMacro ,
66
+ '--inspect=9222'
67
+ ) ;
68
+
69
+ test . serial (
70
+ 'node removes --inspect-brk from nodeOptions when defined by parent process' ,
71
+ inspectMacro ,
72
+ '--inspect-brk'
73
+ ) ;
74
+
75
+ test . serial (
76
+ 'node removes --inspect-brk=9222 from nodeOptions when defined by parent process' ,
77
+ inspectMacro ,
78
+ '--inspect-brk=9222'
79
+ ) ;
80
+
81
+ test . serial (
82
+ 'node should not remove --inspect when passed through nodeOptions' ,
83
+ async t => {
84
+ const { stdout, stderr} = await execa . node ( 'console.log("foo")' , {
85
+ reject : false ,
86
+ nodeOptions : [ '--inspect' , '-e' ]
87
+ } ) ;
88
+
89
+ t . is ( stdout , 'foo' ) ;
90
+ t . true ( stderr . includes ( 'Debugger listening' ) ) ;
91
+ }
92
+ ) ;
93
+
40
94
test ( 'node\'s forked script has a communication channel' , async t => {
41
95
const subprocess = execa . node ( 'test/fixtures/send' ) ;
42
96
subprocess . send ( 'ping' ) ;
0 commit comments