Skip to content

Commit 81b8a0e

Browse files
authored
fix(patch-remove): check if the parameters are valid (#9809)
1 parent 86b33e9 commit 81b8a0e

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

.changeset/wicked-deer-drive.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@pnpm/plugin-commands-patching": patch
3+
---
4+
5+
When executing the `pnpm patch-remove` command, verify whether the passed parameter is a valid patch package name.

patching/plugin-commands-patching/src/patchRemove.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ export async function handler (opts: PatchRemoveCommandOptions, params: string[]
5454
throw new PnpmError('NO_PATCHES_TO_REMOVE', 'There are no patches that need to be removed')
5555
}
5656

57+
for (const patch of patchesToRemove) {
58+
if (!Object.hasOwn(patchedDependencies, patch)) {
59+
throw new PnpmError('PATCH_NOT_FOUND', `Patch "${patch}" not found in patched dependencies`)
60+
}
61+
}
62+
5763
const patchesDirs = new Set<string>()
5864
await Promise.all(patchesToRemove.map(async (patch) => {
5965
if (Object.hasOwn(patchedDependencies, patch)) {

0 commit comments

Comments
 (0)