Repository navigation
util.parseArgs: pick the default args start from a per-VM eval flag, as Node v26 does #44521
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
base: main
Are you sure you want to change the base?
Changes from all commits
61f3cc2
622e26b
ae4f5bb
89b6466
c7c7c06
6d4e125
ebbe332
05735e2
51273ed
eef888c
d1abe26
1ea09a0
2b95f16
38b8dd8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -781,6 +781,24 @@ pub(crate) use bun_bunfig::arguments::{load_config_path, load_config_with_cmd_ar | |
| /// the attached value `e`. Bun's `-p` takes the code, so `-pe X` is `-p X`. | ||
| pub(crate) const NODE_SHORT_ALIASES: &[(&[u8], &[u8])] = &[(b"-pe", b"-p")]; | ||
|
|
||
| /// What the flag of `bun` takes that `is_it` says yes to. `None`: there is no such flag. | ||
| pub(crate) fn values_of(is_it: &dyn Fn(&clap::Names) -> bool) -> Option<&'static clap::Values> { | ||
| let mut flags = AUTO_PARAMS.iter(); | ||
| flags.find(|it| is_it(&it.names)).map(|it| &it.takes_value) | ||
| } | ||
|
|
||
| /// Whether the flag `name`, written `--name` or `-n`, has its value in the argument after it. `None`: `bun` has no such flag. | ||
| pub(crate) fn takes_value(name: &[u8]) -> Option<bool> { | ||
| let alias = NODE_SHORT_ALIASES.iter().find(|(from, _)| *from == name); | ||
| let values = match alias.map_or(name, |(_, to)| *to) { | ||
| [b'-', b'-', long @ ..] => values_of(&|names| names.matches_long(long)), | ||
| [b'-', short] => values_of(&|names| names.short == Some(*short)), | ||
| _ => None, | ||
| }?; | ||
| // An optional value is only ever written `--name=value`. | ||
| Some(matches!(values, clap::Values::One | clap::Values::Many)) | ||
| } | ||
|
Comment on lines
+791
to
+800
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 nit (optional): maintainers get two helpers answering whether a bun flag takes the next token as its value, and the new one ignores short chains. src/runtime/cli/Arguments.rs:795 Why this was flaggedBun's CLI parser chains short flags and lets the last letter take the next token (src/clap/streaming.rs:265-299), so Verification: Trigger: a chained short flag, e.g. a Worker created with
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not changed in this PR. The facts are right:
The description has the case under "Not in this change" (spellings of bun's CLI that the walk does not read). |
||
|
|
||
| /// `--disallow-code-generation-from-strings[=<value>]`. Raises the process's level; never lowers it. | ||
| fn disallow_code_generation_from_strings(value: &[u8]) { | ||
| match bun_core::CodeGenerationFromStrings::from_flag_value(value) { | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| const { parseArgs } = require('util'); | ||
|
|
||
| const parsedArgs = parseArgs({ strict: false }).values; | ||
|
|
||
| process.stdout.write(JSON.stringify(parsedArgs)); |
Uh oh!
There was an error while loading. Please reload this page.