fix: fix the state.json creation path when execute pnpm patch in sub package (#9733)

---------

Co-authored-by: Zoltan Kochan <z@kochan.io>
This commit is contained in:
xiaoliyooo
2025-09-20 08:51:23 +08:00
committed by GitHub
parent c9b6b40117
commit 6633eb3eb0
3 changed files with 8 additions and 2 deletions

View File

@@ -0,0 +1,6 @@
---
"pnpm": patch
"@pnpm/plugin-commands-patching": patch
---
Fix `state.json` creation path when executing `pnpm patch` in a workspace project [#9733](https://github.com/pnpm/pnpm/pull/9733).

View File

@@ -101,7 +101,7 @@ export async function handler (opts: PatchCommandOptions, params: string[]): Pro
writeEditDirState({
editDir,
modulesDir: path.join(opts.dir, opts.modulesDir ?? 'node_modules'),
modulesDir,
patchedPkg: params[0],
applyToAll: patchedDep.applyToAll,
})

View File

@@ -60,7 +60,7 @@ export async function handler (opts: PatchCommitCommandOptions, params: string[]
const editDir = path.resolve(opts.dir, userDir)
const stateValue = readEditDirState({
editDir,
modulesDir: path.join(opts.dir, opts.modulesDir ?? 'node_modules'),
modulesDir: path.join(lockfileDir, opts.modulesDir ?? 'node_modules'),
})
if (!stateValue) {
throw new PnpmError('INVALID_PATCH_DIR', `${userDir} is not a valid patch directory`, {