Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v7.0 #297

Closed
wants to merge 1 commit into from
Closed

v7.0 #297

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
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,15 @@ git commit -m "fix brokenFile.js in some-package"
```

Patches created by `patch-package` are automatically and gracefully applied when
you use `npm`(>=5) or `yarn`.
you use `npm` or `yarn`.

No more waiting around for pull requests to be merged and published. No more
forking repos just to fix that one tiny thing preventing your app from working.
No more waiting around for pull requests to be merged and published! No more
forking repos just to change one line!

ⓘ <em>Is your project a published npm package? If so you should only patch dev
dependencies. Because of the way node_modules folders are managed, patch files
can't be reliably applied for your dependents. `patch-package` won't even
try.</em>

## Set-up

Expand Down
15 changes: 13 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import { getAppRootPath } from "./getAppRootPath"
import { makePatch } from "./makePatch"
import { makeRegExp } from "./makeRegExp"
import { detectPackageManager } from "./detectPackageManager"
import { join } from "./path"
import { normalize, sep } from "path"
import { join, resolve } from "./path"
import { basename, normalize, sep } from "path"
import slash = require("slash")
import isCi from "is-ci"
import { existsSync } from "fs"

const appPath = getAppRootPath()
const argv = minimist(process.argv.slice(2), {
Expand All @@ -33,6 +34,16 @@ console.log(
require(join(__dirname, "../package.json")).version,
)

if (
basename(resolve(process.cwd(), "../")) === "node_modules" &&
existsSync(resolve(process.cwd(), "../../package.json"))
) {
console.log(
`patch-package seems to be running as part of a dependency's postinstall script and will not attempt to apply patches.`,
)
process.exit(0)
}

if (argv.version || argv.v) {
// noop
} else if (argv.help || argv.h) {
Expand Down