Skip to content

Commit b644007

Browse files
committed
more npm/yarn detection back into patch creation
1 parent cd6f70d commit b644007

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

src/applyPatches.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,15 @@ function getInstalledPackageVersion({
5151
return semver.valid(version)
5252
}
5353

54-
export function applyPatchesForApp(
55-
appPath: string,
56-
reverse: boolean,
57-
patchDir: string,
58-
): void {
54+
export function applyPatchesForApp({
55+
appPath,
56+
reverse,
57+
patchDir,
58+
}: {
59+
appPath: string
60+
reverse: boolean
61+
patchDir: string
62+
}): void {
5963
const patchesDirectory = join(appPath, patchDir)
6064
const files = findPatchFiles(patchesDirectory)
6165

src/index.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@ if (argv.version || argv.v) {
3535
} else if (argv.help || argv.h) {
3636
printHelp()
3737
} else {
38-
const packageManager = detectPackageManager(
39-
appPath,
40-
argv["use-yarn"] ? "yarn" : null,
41-
)
4238
const patchDir = slash(normalize((argv["patch-dir"] || "patches") + sep))
4339
if (patchDir.startsWith("/")) {
4440
throw new Error("--patch-dir must be a relative path")
@@ -56,7 +52,10 @@ if (argv.version || argv.v) {
5652
/package\.json$/,
5753
argv["case-sensitive-path-filtering"],
5854
)
59-
55+
const packageManager = detectPackageManager(
56+
appPath,
57+
argv["use-yarn"] ? "yarn" : null,
58+
)
6059
packageNames.forEach((packagePathSpecifier: string) => {
6160
makePatch({
6261
packagePathSpecifier,
@@ -70,7 +69,7 @@ if (argv.version || argv.v) {
7069
} else {
7170
console.log("Applying patches...")
7271
const reverse = !!argv["reverse"]
73-
applyPatchesForApp(appPath, reverse, patchDir)
72+
applyPatchesForApp({ appPath, reverse, patchDir })
7473
}
7574
}
7675

0 commit comments

Comments
 (0)