Files
pnpm/cli/parse-cli-args/test/index.ts
minbang 027196babe fix: parse bare color as boolean flag (#12162)
* fix: parse bare color as boolean flag

Bare --color was treated as an enum-only option, so nopt could
consume the following flag as its value. This prevented command-specific
shorthands such as run --parallel from expanding when --color preceded
them.

Accept boolean values for the color option, and add parser/config
regression coverage for the shorthand case.

Co-authored-by: OpenAI Codex <codex@openai.com>

* test: remove tautological color type metadata test

Per review feedback, the assertion only restated the type metadata; the
behavior is already covered by the parser regression test and the
color-normalization test.

* fix: keep with current dispatch working after a boolean global flag

Bare `--color` now parses as a boolean flag, which enables forms like
`pnpm --color with current <cmd>`. The `with current` rewrite skipped any
occurrence whose preceding token was a long flag without `=`, assuming it
consumed `with` as its value. For boolean flags that is wrong, so the
lookup returned -1 and pnpm threw MISSING_WITH_CURRENT_CMD.

Skip only when the preceding long option actually takes a value, based on
the option type metadata; boolean flags and `--no-` negations no longer
hide the command.

---------

Co-authored-by: OpenAI Codex <codex@openai.com>
Co-authored-by: Zoltan Kochan <z@kochan.io>
2026-06-08 15:04:19 +02:00

20 KiB