Skip to content

fix: --fix applies fixes scoped to the workspace member, not the root - #986

Merged
sonukapoor merged 2 commits into
mainfrom
bugfix/issue-978-fix-apply-workspace-scoping
Aug 14, 2026
Merged

fix: --fix applies fixes scoped to the workspace member, not the root#986
sonukapoor merged 2 commits into
mainfrom
bugfix/issue-978-fix-apply-workspace-scoping

Conversation

@sonukapoor

Copy link
Copy Markdown
Collaborator

The --fix executor built its install command through buildFixCommandParts, which produced an unscoped command. In a monorepo that meant a direct fix was installed at the repository root instead of the workspace member that actually declares the dependency, so the change landed in the wrong package.json.

#972 corrected the commands we display, but the executor still built its own unscoped command, so what --fix applied could diverge from what we showed.

This extracts buildTargetCommand, shared by both the display path and the apply path, so the command that runs is exactly the command shown, scoped to the declaring workspace member. Commands for multiple members joined with && are split and spawned individually. The now-dead buildFixCommandParts is removed.

In-house.

Closes #978

The --fix executor built its install command via buildFixCommandParts,
which produced a flat, unscoped `npm install X@ver` / `pnpm add X@ver`. In
a monorepo that installs the fix into the root manifest instead of the
member that declares it. #972 fixed all the displayed/copy-run commands
but not the executor.

Extract buildTargetCommand in fix-commands.ts (the workspace-scoped
per-target command, factored out of findSuggestedCommandForFinding) and
use it in the apply path so the displayed command and the applied command
are identical. Multi-member commands are `&&`-split into one spawn each.
Removes the now-dead buildFixCommandParts.
Covers the workspace-scoped direct apply (npm install -w <member> ...)
and the flat non-workspace case via the injected command runner. Adds the
new buildTargetCommand export to the cli-integration fix-commands mock.
@sonukapoor
sonukapoor merged commit 58ed26b into main Aug 14, 2026
6 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.

fix: --fix applies direct fixes unscoped at the workspace root instead of the declaring member

1 participant