Uh oh!
There was an error while loading. Please reload this page.
src: list scripts when --run has no command - #64606
Conversation
nodejs-github-bot
commented
Jul 19, 2026
Review requested:
|
| // `--run` may be passed without a script name to list available scripts, | ||
| // so an omitted value is not an error and must not swallow a later flag. | ||
| const bool optional_value = name == "--run"; |
There was a problem hiding this comment.
Is there a better solution to modifying the options parser directly? We have other CLI flags that have different behavior depending on whether or not they have an argument passed?
How does --inspect do this?
There was a problem hiding this comment.
I'm not entirely familiar with the code, but looking at --inspect, it's a boolean option so works a bit differently I think:
Lines 475 to 479 in 0bcc6ef
So --inspect and --inspect=1234 work, but --inspect 1234 isn't valid.
If I'm understanding correctly, --run can't do this, because it's space separated.
To avoid the hardcoded name == "--run", what would you suggest?
There was a problem hiding this comment.
hmm, perhaps I was mis-remembering that --inspect required an = to run 😓. I'm still wary about changing the parser, since there probably should be a way for a flag to be passed with an optional value, regardless of =.
Sorry about misremembering, I'll ask around to see if there's a way to do this, and if not, we can always add it.
There was a problem hiding this comment.
thanks! It's also very possible I'm misreading this or missing something, and this is already supported somewhere - sorry if so!
There was a problem hiding this comment.
I doubt that, you (so far) demonstrate a great understanding of the codebase. It's probable that we just never encountered this scenario before.
Great work so far :-)
Uh oh!
There was an error while loading. Please reload this page.
avivkeller
commented
Jul 19, 2026
Implementation LGTM. I'm not giving this the green check while I look into better ways of actually detecting the option-less flag, but everything from that point on is great :) |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@## main #64606 +/- ##
==========================================
+ Coverage 90.11% 90.13% +0.01%
==========================================
Files 752 752 Lines 251861 251873 +12 Branches 47365 47363 -2 ==========================================
+ Hits 226955 227016 +61 + Misses 16238 16186 -52 - Partials 8668 8671 +3
🚀 New features to boost your workflow:
|
Cherry
commented
Jul 20, 2026
Just pushed to fix the markdown linting - looks like I needed to prepend to The macOS test failure looks to be an unrelated flake, but let me know if not. |
anonrig
commented
Jul 31, 2026
Thank you James! @Cherry |
This comment was marked as outdated.
This comment was marked as outdated.
Renegade334
commented
Jul 31, 2026
GHA is borked on the current PR head, and looks like there will be lint issues to address anyway, so I'm just going to trigger a rebase. |
a39f0dc to
95d7a9aCompareCherry
commented
Jul 31, 2026
Let me know if I can help with any of the linting (etc.) issues! Thanks all. |
anonrig
commented
Jul 31, 2026
@Cherry can you rebase and ask your agent to fix the linting errors please? |
Renegade334
commented
Jul 31, 2026
The only complaint appears to be: |
Cherry
commented
Jul 31, 2026
Yeah I can rebase and try and fix that shortly! |
Cherry
commented
Jul 31, 2026
Should be good now, thanks! |
nodejs-github-bot
commented
Jul 31, 2026
jasnell
commented
Aug 2, 2026
Overall fine with the idea, but there's a subtly that's worth calling out. $ export CMD=test
$ node --run $CMD
// Runs the test script
$ export CMD=
$ node --run $CMD
// Lists the available scriptsRe-using the |
Yeah that's a fair point, though I think this edge-case is a pretty common shell thing - for example That said, since |
jasnell
commented
Aug 2, 2026
That sounds like a reasonable approach to me. |
Cherry
commented
Aug 3, 2026
Updated to do a non-zero exit (9 seemed the most appropriate looking at other codes, but happy to tweak), and then print to stderrr. Let me know if there's any other feedback! |
CI is looking good! Let me know if there's anything further I can do to help land this. Pushed up changes to resolve the merge conflicts. |
Signed-off-by: James Ross <james@jross.me>
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
nodejs-github-bot
commented
Aug 23, 2026
Uh oh!
There was an error while loading. Please reload this page.
nodejs-github-bot
commented
Aug 24, 2026
Landed in 5e48fb3 |
This extends the behaviour when you run
node --run <unknown script>that prints a list of available scripts, to now print available scripts when you simply runnode --run, to mimic the behaviour ofnpm run, etc.Previously,
node --runwith no command errored with--run requires an argument.This is my first contribution to Node.js so while I've tried to read and follow everything, please let me know if I'm missing anything!
Fixes: #64870