fix(patch-remove): check if the parameters are valid (#9809)

This commit is contained in:
btea
2025-07-31 20:02:46 +08:00
committed by GitHub
parent 86b33e91ea
commit 81b8a0eacb
2 changed files with 11 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
---
"@pnpm/plugin-commands-patching": patch
---
When executing the `pnpm patch-remove` command, verify whether the passed parameter is a valid patch package name.

View File

@@ -54,6 +54,12 @@ export async function handler (opts: PatchRemoveCommandOptions, params: string[]
throw new PnpmError('NO_PATCHES_TO_REMOVE', 'There are no patches that need to be removed')
}
for (const patch of patchesToRemove) {
if (!Object.hasOwn(patchedDependencies, patch)) {
throw new PnpmError('PATCH_NOT_FOUND', `Patch "${patch}" not found in patched dependencies`)
}
}
const patchesDirs = new Set<string>()
await Promise.all(patchesToRemove.map(async (patch) => {
if (Object.hasOwn(patchedDependencies, patch)) {