diff --git a/lib/bootstrap.js b/lib/bootstrap.js index 87234a5ac81..89613aedcfd 100644 --- a/lib/bootstrap.js +++ b/lib/bootstrap.js @@ -48,7 +48,7 @@ async function runCLI(cli, commandIsUsed) { let args; const helpFlagExists = isFlagPresent(process.argv, 'help'); const versionFlagExists = isFlagPresent(process.argv, 'version'); - const nodeArgsExists = isFlagPresent(process.argv, 'node-args'); + const nodeArgsExists = process.argv.find(arg => arg.includes('--node-args')); if (helpFlagExists) { cli.runHelp(process.argv); @@ -111,7 +111,6 @@ async function runCLI(cli, commandIsUsed) { const newArgKeys = Object.keys(argsMap).filter(arg => !keysToDelete.includes(argsMap[arg].pos)); // eslint-disable-next-line require-atomic-updates process.argv = newArgKeys; - args = cmdArgs(core, { stopAtFirstUnknown: false, partial: true }); await cli.run(args, core); process.stdout.write('\n'); diff --git a/lib/utils/parse-args.js b/lib/utils/parse-args.js index d504c14e614..3285410ae70 100644 --- a/lib/utils/parse-args.js +++ b/lib/utils/parse-args.js @@ -14,6 +14,9 @@ module.exports = rawArgs => { for (const value of rawArgs) { if (value === '--node-args') { isNodeArg = true; + } else if (value.startsWith('--node-args=')) { + const [, argValue] = value.match(/^--node-args="?(.+?)"?$/); + nodeArgs.push(argValue); } else if (isNodeArg) { isNodeArg = false; nodeArgs.push(...value.split(' ')); diff --git a/test/node/node.test.js b/test/node/node.test.js index 469268affcd..d2396935b37 100644 --- a/test/node/node.test.js +++ b/test/node/node.test.js @@ -18,9 +18,9 @@ describe('node flags', () => { expectedNodeArgs: ['--name1=value1', '--name2', 'value2'], }, { - rawArgs: ['--node-args', '--name1=value1', '--node-args', '--name2 value2', '--node-args', '-n=v', '--node-args', '-k v'], + rawArgs: ['--node-args', '--name1=value1', '--node-args', '--name2="value2"', '--node-args', '--name3 value3', '--node-args', '-k v'], expectedCliArgs: [], - expectedNodeArgs: ['--name1=value1', '--name2', 'value2', '-n=v', '-k', 'v'], + expectedNodeArgs: ['--name1=value1', '--name2="value2"', '--name3', 'value3', '-k', 'v'], }, ].map(({ rawArgs, expectedNodeArgs, expectedCliArgs }) => { const { nodeArgs, cliArgs } = parseArgs(rawArgs);