Skip to content

Commit 69c6a0f

Browse files
committed
fix: throw an error if package details are not passed to applyPatch function
1 parent 0b9b015 commit 69c6a0f

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/applyPatches.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,8 @@ export function applyPatch({
242242
}: {
243243
patchFilePath: string
244244
reverse: boolean
245-
packageDetails: PackageDetails
246-
patchDir: string
245+
packageDetails?: PackageDetails
246+
patchDir?: string
247247
}): boolean {
248248
const patch = readPatch({ patchFilePath, packageDetails, patchDir })
249249
try {

src/patch/read.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@ export function readPatch({
1111
patchDir,
1212
}: {
1313
patchFilePath: string
14-
packageDetails: PackageDetails
15-
patchDir: string
14+
packageDetails?: PackageDetails
15+
patchDir?: string
1616
}): PatchFilePart[] {
1717
try {
1818
return parsePatchFile(readFileSync(patchFilePath).toString())
1919
} catch (e) {
20+
if (packageDetails == null || patchDir == null) {
21+
throw e
22+
}
2023
const fixupSteps: string[] = []
2124
const relativePatchFilePath = normalize(
2225
relative(process.cwd(), patchFilePath),

0 commit comments

Comments
 (0)