File tree 2 files changed +13
-1
lines changed
2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -68,6 +68,7 @@ exports.impliesNoTimeouts = flag => debugFlags.has(flag);
68
68
/**
69
69
* All non-strictly-boolean arguments to node--those with values--must specify those values using `=`, e.g., `--inspect=0.0.0.0`.
70
70
* Unparse these arguments using `yargs-unparser` (which would result in `--inspect 0.0.0.0`), then supply `=` where we have values.
71
+ * Apparently --require in Node.js v8 does NOT want `=`.
71
72
* There's probably an easier or more robust way to do this; fixes welcome
72
73
* @param {Object } opts - Arguments object
73
74
* @returns {string[] } Unparsed arguments using `=` to specify values
@@ -79,7 +80,9 @@ exports.unparseNodeFlags = opts => {
79
80
? args
80
81
. join ( ' ' )
81
82
. split ( / \b / )
82
- . map ( arg => ( arg === ' ' ? '=' : arg ) )
83
+ . map ( ( arg , index , args ) =>
84
+ arg === ' ' && args [ index - 1 ] !== 'require' ? '=' : arg
85
+ )
83
86
. join ( '' )
84
87
. split ( ' ' )
85
88
: [ ] ;
Original file line number Diff line number Diff line change @@ -134,5 +134,14 @@ describe('node-flags', function() {
134
134
[ '--v8-numeric-one=1' , '--v8-boolean-one' , '--v8-numeric-two=2' ]
135
135
) ;
136
136
} ) ;
137
+
138
+ it ( 'should special-case "--require"' , function ( ) {
139
+ // note the only way for this to happen IN REAL LIFE is if you use "--require esm";
140
+ // mocha eats all --require args otherwise.
141
+ expect ( unparseNodeFlags ( { require : 'mcrib' } ) , 'to equal' , [
142
+ '--require' ,
143
+ 'mcrib'
144
+ ] ) ;
145
+ } ) ;
137
146
} ) ;
138
147
} ) ;
You can’t perform that action at this time.
0 commit comments