Repository navigation
feat(@angular/cli): forward arguments after -- to supporting builders - #34731
Merged
Merged
Conversation
clydin
marked this pull request as ready for review
November 16, 2026 16:28
There was a problem hiding this comment.
Code Review
This pull request introduces support for forwarding command-line arguments following -- (passthrough arguments) to builders that support them, specifically targeting the Vitest unit test runner via the x-passthrough schema option. It updates the command execution pipeline to parse, validate, and concatenate these arguments with existing options, and adds comprehensive unit and end-to-end tests. The review feedback suggests improving robustness by verifying that the target passthrough option is indeed an array and handling cases where existing option values are non-array scalars.
Previously, `createNormalizeOptionsMiddleware` treated `--` (populated by yargs when `'populate--': true` is enabled) like any non-array option, collapsing its array to the last element and logging a spurious warning. In addition, `CommandModule.handler` only stripped `_` and `$0` from parsed arguments, allowing `--` to leak into `camelCasedOptions` and be forwarded to commands as an unexpected option. Exclude `--` from option normalization, extract `--` in `CommandModule.handler` into `passthroughArgs`, and reject non-empty `--` arguments with a `CommandModuleError` for commands that do not opt into `acceptsPassthroughArgs`.
Allow architect-backed commands (`ng test`, `ng run`, etc.) to forward arguments after `--` to builders that explicitly opt in via the `"x-passthrough": true` schema keyword on an array option. This adds a `passthrough` flag to `Option` parsed from `"x-passthrough"` in `parseJsonSchemaToOptions`, enables `acceptsPassthroughArgs` on `ArchitectBaseCommandModule`, and updates `runSingleTarget` to route `passthroughArgs` to the target builder's `x-passthrough` option (appending after any explicit option values) or throw a `CommandModuleError` when the builder does not declare one. The `@angular/build` `unit-test` builder marks `runnerArgs` with `"x-passthrough": true` so `ng test -- <args>` forwards arguments to Vitest. The `ng test` help description and Vitest snapshot e2e test are updated accordingly.
clydin
force-pushed
the
cli-passthrough-args
branch
from
November 16, 2026 16:48
5b2c930 to
64aff7a
Compare
alan-agius4
approved these changes
Nov 17, 2026
Collaborator
|
This PR was merged into the repository. The changes were merged into the following branches:
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Allow architect-backed commands (
ng test,ng run, etc.) to forwardarguments after
--to builders that explicitly opt in via the"x-passthrough": trueschema keyword on an array option.This adds a
passthroughflag toOptionparsed from"x-passthrough"in
parseJsonSchemaToOptions, enablesacceptsPassthroughArgsonArchitectBaseCommandModule, and updatesrunSingleTargetto routepassthroughArgsto the target builder'sx-passthroughoption(appending after any explicit option values) or throw a
CommandModuleErrorwhen the builder does not declare one.The
@angular/buildunit-testbuilder marksrunnerArgswith"x-passthrough": truesong test -- <args>forwards arguments toVitest. The
ng testhelp description and Vitest snapshot e2e test areupdated accordingly.
Closes #32218
Closes #32726
Partially Addresses #32343