refactor: add recursiveByDefault property to CommandDefinition#11062
Merged
Conversation
Replace the hardcoded command name list in main.ts with a declarative recursiveByDefault property on CommandDefinition. Each command that should run workspace-wide by default now exports this property. Also adds recursiveByDefault to list, ll, and why commands. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors how pnpm decides to default certain commands to workspace-wide (recursive) execution by moving the decision into each command’s definition (recursiveByDefault) and deriving the default-recursive command set from those definitions.
Changes:
- Add
recursiveByDefault?: booleantoCommandDefinitionand export a derivedrecursiveByDefaultCommandsset. - Update
main.tsto userecursiveByDefaultCommandsinstead of a hardcoded command-name condition. - Opt additional commands (
list,ll,why, plus previously hardcoded ones likeinstall,dedupe,patch*,approve-builds,audit) into recursive-by-default behavior.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| pnpm/src/main.ts | Switches default-recursive condition to use a derived command set. |
| pnpm/src/cmd/index.ts | Adds recursiveByDefault to the command definition shape and builds recursiveByDefaultCommands. |
| patching/commands/src/patchRemove.ts | Marks patch-remove as recursive-by-default via command definition export. |
| patching/commands/src/patchCommit.ts | Marks patch-commit as recursive-by-default via command definition export. |
| patching/commands/src/patch.ts | Marks patch as recursive-by-default via command definition export. |
| installing/commands/src/install.ts | Marks install as recursive-by-default via command definition export. |
| installing/commands/src/import/index.ts | Marks import as recursive-by-default via command definition export. |
| installing/commands/src/dedupe.ts | Marks dedupe as recursive-by-default via command definition export. |
| deps/inspection/commands/src/listing/why.ts | Marks why as recursive-by-default via command definition export. |
| deps/inspection/commands/src/listing/ll.ts | Marks ll/la as recursive-by-default via command definition export. |
| deps/inspection/commands/src/listing/list.ts | Marks list/ls as recursive-by-default via command definition export. |
| deps/compliance/commands/src/audit/audit.ts | Marks audit as recursive-by-default via command definition export. |
| building/commands/src/policy/approveBuilds.ts | Marks approve-builds as recursive-by-default via command definition export. |
Comments suppressed due to low confidence (1)
pnpm/src/main.ts:197
- This block forces
recursive=truefor commands markedrecursiveByDefaulteven if the user explicitly passed--no-recursive(or otherwise setrecursiveto false) on the CLI. With more commands now opting into the default, this becomes a user-visible regression for disabling workspace-wide behavior. Consider only applying the default whencliOptions.recursiveisundefined(or not present), and leave explicittrue/falseuntouched (same forconfig.recursive).
if (
cmd != null && recursiveByDefaultCommands.has(cmd) &&
typeof workspaceDir === 'string'
) {
cliOptions['recursive'] = true
config.recursive = true
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
recursiveByDefaultproperty toCommandDefinitionso commands can declaratively opt into running workspace-wide by defaultmain.tswith a set built from command definitionsrecursiveByDefaulttolist,ll, andwhycommands (in addition to the previously hardcodedinstall,import,dedupe,patch,patch-commit,patch-remove,approve-builds,audit)Test plan
🤖 Generated with Claude Code