File tree Expand file tree Collapse file tree 2 files changed +20
-5
lines changed Expand file tree Collapse file tree 2 files changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -18,10 +18,14 @@ git commit -m "fix brokenFile.js in some-package"
1818```
1919
2020Patches created by ` patch-package ` are automatically and gracefully applied when
21- you use ` npm ` (>=5) or ` yarn ` .
21+ you use ` npm ` or ` yarn ` .
2222
23- No more waiting around for pull requests to be merged and published. No more
24- forking repos just to fix that one tiny thing preventing your app from working.
23+ No more waiting around for pull requests to be merged and published! No more
24+ forking repos just to change one line!
25+
26+ ⓘ <em >Is your project a published npm package? If so you should only patch dev
27+ dependencies. Patch files can't reliably be applied for your
28+ dependents—` patch-package ` won't even try.</em >
2529
2630## Set-up
2731
Original file line number Diff line number Diff line change @@ -7,10 +7,11 @@ import { getAppRootPath } from "./getAppRootPath"
77import { makePatch } from "./makePatch"
88import { makeRegExp } from "./makeRegExp"
99import { detectPackageManager } from "./detectPackageManager"
10- import { join } from "./path"
11- import { normalize , sep } from "path"
10+ import { join , resolve } from "./path"
11+ import { basename , normalize , sep } from "path"
1212import slash = require( "slash" )
1313import isCi from "is-ci"
14+ import { existsSync } from "fs"
1415
1516const appPath = getAppRootPath ( )
1617const argv = minimist ( process . argv . slice ( 2 ) , {
@@ -33,6 +34,16 @@ console.log(
3334 require ( join ( __dirname , "../package.json" ) ) . version ,
3435)
3536
37+ if (
38+ basename ( resolve ( process . cwd ( ) , "../" ) ) === "node_modules" &&
39+ existsSync ( resolve ( process . cwd ( ) , "../../package.json" ) )
40+ ) {
41+ console . log (
42+ `patch-package seems to be running as part of a dependency's postinstall script and will not attempt to apply patches.` ,
43+ )
44+ process . exit ( 0 )
45+ }
46+
3647if ( argv . version || argv . v ) {
3748 // noop
3849} else if ( argv . help || argv . h ) {
You can’t perform that action at this time.
0 commit comments