Skip to content

fix(node_shim): preserve explicit argument delimiters - #36435

Merged
bartlomieju merged 2 commits into
denoland:mainfrom
nathanwhit:fix/node-shim-explicit-argument-delimiter
Aug 13, 2026
Merged

bartlomieju merged 2 commits into
denoland:mainfrom
nathanwhit:fix/node-shim-explicit-argument-delimiter

Conversation

@nathanwhit

Copy link
Copy Markdown
Member

Summary

  • record when Node option parsing stops at an explicit --
  • restore that delimiter before translated positional arguments
  • keep Deno subcommand passthrough unchanged when no delimiter was supplied

Details

Node argument parsing removes the option delimiter before translation, which previously made explicitly-delimited arguments indistinguishable from ordinary remaining arguments. The parse result now retains that state so translated task, test, and script invocations preserve the original positional-argument boundary. Deno-style subcommand passthrough remains available only on the existing no-delimiter path.

Validation

  • ./tools/format.js libs/node_shim/lib.rs --check
  • cargo test -p node_shim -- --nocapture
  • cargo check -p node_shim --all-targets
  • cargo check -p deno_node --features deno_core/v8

@bartlomieju bartlomieju left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Correct fix. Dropping -- during parsing made node -- eval foo.js indistinguishable from node eval foo.js, so the is_deno_subcommand passthrough would hijack it and run deno eval instead of a script named eval. Gating that passthrough on !had_double_dash is the right call — after an explicit --, Node treats the next argument as the script name unconditionally, so there's nothing to sniff.

Checked that append_remaining_args is applied at all four deno_args.extend(parsed_args.remaining_args) sites (task, the middle branch, and the final script path), so no branch silently drops the delimiter. Guarding on !remaining_args.is_empty() avoids emitting a trailing bare --.

Both new tests pin the cases that actually mattered: a subcommand-looking script name, and a flag-looking script name that would otherwise be eaten by deno run. LGTM.

@bartlomieju
bartlomieju enabled auto-merge (squash) August 10, 2026 14:27
@bartlomieju
bartlomieju merged commit c64bb8e into denoland:main Aug 13, 2026
268 of 270 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants