Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ which is a diff between normal old `package-name` and your fixed version. Commit

Make regexps used in --include or --exclude filters case-sensitive.

* `--patches-dir`

Specifies patches directory. defaults to `patches`

### Updating patches

Use exactly the same process as for making patches in the first place, i.e. make more changes, run patch-package, commit the changes to the patch file.
Expand All @@ -105,6 +109,10 @@ Run `patch-package` without arguments to apply all patches in your project.

This option was added to help people using CircleCI avoid [an issue around caching and patch file updates](https://github.com/ds300/patch-package/issues/37) but might be useful in other contexts too.

* `--patches-dir`

Specifies patches directory. defaults to `patches`

#### Notes

To apply patches individually, you may use `git`:
Expand Down
3 changes: 2 additions & 1 deletion src/applyPatches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ function getInstalledPackageVersion(
export const applyPatchesForApp = (
appPath: AppPath,
reverse: boolean,
patchDir: string = "patches",
): void => {
const patchesDirectory = path.join(appPath, "patches") as PatchesDirectory
const patchesDirectory = path.join(appPath, patchDir) as PatchesDirectory
const files = findPatchFiles(patchesDirectory)

if (files.length === 0) {
Expand Down
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { detectPackageManager } from "./detectPackageManager"
const appPath = getAppRootPath()
const argv = minimist(process.argv.slice(2), {
boolean: ["use-yarn", "case-sensitive-path-filtering", "reverse"],
string: ["patch-dir"],
})
const packageNames = argv._

Expand All @@ -37,11 +38,12 @@ if (argv.help || argv.h) {
detectPackageManager(appPath, argv["use-yarn"] ? "yarn" : null),
include,
exclude,
argv["patch-dir"],
)
})
} else {
console.log("patch-package: Applying patches...")
applyPatchesForApp(appPath, !!argv["reverse"])
applyPatchesForApp(appPath, !!argv["reverse"], argv["patch-dir"])
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/makePatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const makePatch = (
packageManager: PackageManager,
includePaths: RegExp,
excludePaths: RegExp,
patchDir: string = "patches",
) => {
const nodeModulesPath = join(appPath, "node_modules")
const packagePath = join(nodeModulesPath, packageName)
Expand All @@ -53,7 +54,7 @@ export const makePatch = (
const tmpRepoPackagePath = join(tmpRepoNodeModulesPath, packageName)

try {
const patchesDir = join(appPath, "patches")
const patchesDir = join(appPath, patchDir)

if (!fs.existsSync(patchesDir)) {
fs.mkdirSync(patchesDir)
Expand Down Expand Up @@ -183,7 +184,7 @@ export const makePatch = (
fs.mkdirSync(dirname(patchPath))
}
fs.writeFileSync(patchPath, patch)
console.log(`${green("✔")} Created file patches/${patchFileName}`)
console.log(`${green("✔")} Created file ${patchDir}/${patchFileName}`)
}
} catch (e) {
console.error(e)
Expand Down