util: fix parseArgs skipping first positional arg with --eval= and --…
Fix: handle --eval= and --print= correctly in getMainArgs()
Fixes #60808
parseArgs() was skipping the first positional argument when Node was started
with --eval= or --print=. The logic only checked for --eval / --print
and missed the --eval=... / --print=... forms.
This patch adds startsWith('--eval=') and startsWith('--print=') checks so
getMainArgs() returns the correct slice of process.argv.
After this fix, positional arguments are preserved correctly for all eval/print forms.
Codecov Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 88.53%. Comparing base (7fd3688) to head (dc3236b).
:warning: Report is 119 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #60814 +/- ##
==========================================
- Coverage 88.56% 88.53% -0.03%
==========================================
Files 703 703
Lines 208254 208425 +171
Branches 40156 40197 +41
==========================================
+ Hits 184430 184537 +107
- Misses 15828 15893 +65
+ Partials 7996 7995 -1
| Files with missing lines | Coverage Δ | |
|---|---|---|
| lib/internal/util/parse_args/parse_args.js | 99.26% <100.00%> (-0.01%) |
:arrow_down: |
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
Thanks for the guidance, appreciate it!
CI: https://ci.nodejs.org/job/node-test-pull-request/70315/
CI: https://ci.nodejs.org/job/node-test-pull-request/70319/
Nice catch and change. I like checking the internal options instead of doing a pseudo parse of execArgv.
Just checking in — let me know if anything else is required from me.
There's https://github.com/nodejs/node/pull/60814#pullrequestreview-3540315205 regarding the order of the test assertions, otherwise all good 👍
CI: https://ci.nodejs.org/job/node-test-pull-request/70453/
CI: https://ci.nodejs.org/job/node-test-pull-request/70459/
Landed in 060deae99b03