File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 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);
6868/**
6969 * All non-strictly-boolean arguments to node--those with values--must specify those values using `=`, e.g., `--inspect=0.0.0.0`.
7070 * 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 `=`.
7172 * There's probably an easier or more robust way to do this; fixes welcome
7273 * @param {Object } opts - Arguments object
7374 * @returns {string[] } Unparsed arguments using `=` to specify values
@@ -79,7 +80,9 @@ exports.unparseNodeFlags = opts => {
7980 ? args
8081 . join ( ' ' )
8182 . split ( / \b / )
82- . map ( arg => ( arg === ' ' ? '=' : arg ) )
83+ . map ( ( arg , index , args ) =>
84+ arg === ' ' && args [ index - 1 ] !== 'require' ? '=' : arg
85+ )
8386 . join ( '' )
8487 . split ( ' ' )
8588 : [ ] ;
Original file line number Diff line number Diff line change @@ -134,5 +134,14 @@ describe('node-flags', function() {
134134 [ '--v8-numeric-one=1' , '--v8-boolean-one' , '--v8-numeric-two=2' ]
135135 ) ;
136136 } ) ;
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+ } ) ;
137146 } ) ;
138147} ) ;
You can’t perform that action at this time.
0 commit comments