Skip to content

feat(@angular/cli): forward arguments after -- to supporting builders - #34731

Merged
alan-agius4 merged 2 commits into
angular:mainfrom
clydin:cli-passthrough-args
Nov 17, 2026
Merged

alan-agius4 merged 2 commits into
angular:mainfrom
clydin:cli-passthrough-args

Conversation

@clydin

@clydin clydin commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

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.

Closes #32218
Closes #32726
Partially Addresses #32343

@clydin clydin added the target: minor This PR is targeted for the next minor release label Nov 16, 2026
@angular-robot angular-robot Bot added detected: feature PR contains a feature commit area: @angular/cli labels Nov 16, 2026
@clydin
clydin marked this pull request as ready for review November 16, 2026 16:28

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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
clydin force-pushed the cli-passthrough-args branch from 5b2c930 to 64aff7a Compare November 16, 2026 16:48
@clydin clydin added the action: review The PR is still awaiting reviews from at least one requested reviewer label Nov 16, 2026
@clydin
clydin requested a review from alan-agius4 November 16, 2026 16:53
@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Nov 17, 2026
@alan-agius4
alan-agius4 merged commit 0b17e0b into angular:main Nov 17, 2026
41 checks passed
@alan-agius4

Copy link
Copy Markdown
Collaborator

This PR was merged into the repository. The changes were merged into the following branches:

@clydin
clydin deleted the cli-passthrough-args branch November 17, 2026 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: @angular/cli detected: feature PR contains a feature commit target: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Easier way to provide disableConsoleIntercept to ng test with vitest Allow to pass --update to vitest

2 participants