File tree Expand file tree Collapse file tree 1 file changed +9
-8
lines changed
lib/internal/util/parse_args Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -56,21 +56,22 @@ const {
5656
5757
5858function getMainArgs ( ) {
59- // Work out where to slice process.argv for user supplied arguments.
60-
61- // Check node options for scenarios where user CLI args follow executable.
6259 const execArgv = process . execArgv ;
63- if ( ArrayPrototypeIncludes ( execArgv , '-e' ) ||
64- ArrayPrototypeIncludes ( execArgv , '--eval' ) ||
65- ArrayPrototypeIncludes ( execArgv , '-p' ) ||
66- ArrayPrototypeIncludes ( execArgv , '--print' ) ) {
60+
61+ const hasEvalOrPrint = execArgv . some ( arg =>
62+ arg === '-e' || arg === '--eval' ||
63+ arg === '-p' || arg === '--print' ||
64+ arg . startsWith ( '--eval=' ) || arg . startsWith ( '--print=' )
65+ ) ;
66+
67+ if ( hasEvalOrPrint ) {
6768 return ArrayPrototypeSlice ( process . argv , 1 ) ;
6869 }
6970
70- // Normally first two arguments are executable and script, then CLI arguments
7171 return ArrayPrototypeSlice ( process . argv , 2 ) ;
7272}
7373
74+
7475/**
7576 * In strict mode, throw for possible usage errors like --foo --bar
7677 * @param {object } token - from tokens as available from parseArgs
You can’t perform that action at this time.
0 commit comments