-
-
Notifications
You must be signed in to change notification settings - Fork 36.2k
src: list scripts when --run has no command
#64606
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Cherry
wants to merge
1
commit into
nodejs:main
Choose a base branch
from
Cherry:run-list-scripts
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| 'use strict'; | ||
|
|
||
| require('../common'); | ||
| const assert = require('node:assert/strict'); | ||
| const childProcess = require('node:child_process'); | ||
| const fixtures = require('../common/fixtures'); | ||
|
|
||
| const child = childProcess.spawnSync( | ||
| process.execPath, | ||
| [ '--no-warnings', '--run'], | ||
| { cwd: fixtures.path('run-script'), encoding: 'utf8' }, | ||
| ); | ||
| assert.strictEqual(child.status, 0); | ||
| console.log(child.stdout); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| Available scripts are: | ||
| test: echo "Error: no test specified" && exit 1 | ||
| ada: ada | ||
| ada-windows: ada.bat | ||
| positional-args: positional-args | ||
| positional-args-windows: positional-args.bat | ||
| custom-env: custom-env | ||
| custom-env-windows: custom-env.bat | ||
| path-env: path-env | ||
| path-env-windows: path-env.bat | ||
| special-env-variables: special-env-variables | ||
| special-env-variables-windows: special-env-variables.bat | ||
| pwd: pwd | ||
| pwd-windows: cd |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
--inspectdo this?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not entirely familiar with the code, but looking at
--inspect, it's a boolean option so works a bit differently I think:node/src/node_options.cc
Lines 475 to 479 in 0bcc6ef
So
--inspectand--inspect=1234work, but--inspect 1234isn't valid.If I'm understanding correctly,
--runcan'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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, perhaps I was mis-remembering that
--inspectrequired 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 :-)