Skip to content

Commit

Permalink
more npm/yarn detection back into patch creation
Browse files Browse the repository at this point in the history
  • Loading branch information
ds300 committed Mar 24, 2019
1 parent cd6f70d commit b644007
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
14 changes: 9 additions & 5 deletions src/applyPatches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,15 @@ function getInstalledPackageVersion({
return semver.valid(version)
}

export function applyPatchesForApp(
appPath: string,
reverse: boolean,
patchDir: string,
): void {
export function applyPatchesForApp({
appPath,
reverse,
patchDir,
}: {
appPath: string
reverse: boolean
patchDir: string
}): void {
const patchesDirectory = join(appPath, patchDir)
const files = findPatchFiles(patchesDirectory)

Expand Down
11 changes: 5 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ if (argv.version || argv.v) {
} else if (argv.help || argv.h) {
printHelp()
} else {
const packageManager = detectPackageManager(
appPath,
argv["use-yarn"] ? "yarn" : null,
)
const patchDir = slash(normalize((argv["patch-dir"] || "patches") + sep))
if (patchDir.startsWith("/")) {
throw new Error("--patch-dir must be a relative path")
Expand All @@ -56,7 +52,10 @@ if (argv.version || argv.v) {
/package\.json$/,
argv["case-sensitive-path-filtering"],
)

const packageManager = detectPackageManager(
appPath,
argv["use-yarn"] ? "yarn" : null,
)
packageNames.forEach((packagePathSpecifier: string) => {
makePatch({
packagePathSpecifier,
Expand All @@ -70,7 +69,7 @@ if (argv.version || argv.v) {
} else {
console.log("Applying patches...")
const reverse = !!argv["reverse"]
applyPatchesForApp(appPath, reverse, patchDir)
applyPatchesForApp({ appPath, reverse, patchDir })
}
}

Expand Down

0 comments on commit b644007

Please sign in to comment.