Skip to content

Conversation

@azadgupta1
Copy link
Contributor

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.

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. util Issues and PRs related to the built-in util module. labels Nov 22, 2025
Copy link
Contributor

@IlyasShabi IlyasShabi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add tests please

@codecov
Copy link

codecov bot commented Nov 22, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.55%. Comparing base (7fd3688) to head (edb11e6).
⚠️ Report is 28 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #60814      +/-   ##
==========================================
- Coverage   88.56%   88.55%   -0.01%     
==========================================
  Files         703      703              
  Lines      208254   208254              
  Branches    40156    40165       +9     
==========================================
- Hits       184430   184428       -2     
- Misses      15828    15830       +2     
  Partials     7996     7996              
Files with missing lines Coverage Δ
lib/internal/util/parse_args/parse_args.js 99.26% <100.00%> (-0.01%) ⬇️

... and 54 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@azadgupta1 azadgupta1 force-pushed the fix-eval-args branch 2 times, most recently from bc85468 to 8ed13dc Compare November 23, 2025 06:39
@azadgupta1 azadgupta1 force-pushed the fix-eval-args branch 2 times, most recently from a89d8c5 to 5919b08 Compare November 25, 2025 04:10
Copy link
Member

@Renegade334 Renegade334 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this!

@Renegade334 Renegade334 added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Nov 25, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Nov 25, 2025
@azadgupta1
Copy link
Contributor Author

Thanks for the guidance, appreciate it!

@Renegade334 Renegade334 added the request-ci Add this label to start a Jenkins CI on a PR. label Nov 25, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Nov 25, 2025
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no pending requests for changes, and a CI started. needs-ci PRs that need a full CI run. util Issues and PRs related to the built-in util module.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

util.parseArgs() omits the first positional argument when used with the --eval= option

4 participants