File tree 2 files changed +21
-5
lines changed
2 files changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -18,10 +18,15 @@ git commit -m "fix brokenFile.js in some-package"
18
18
```
19
19
20
20
Patches created by ` patch-package ` are automatically and gracefully applied when
21
- you use ` npm ` (>=5) or ` yarn ` .
21
+ you use ` npm ` or ` yarn ` .
22
22
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. Because of the way node_modules folders are managed, patch files
28
+ can't be reliably applied for your dependents. ` patch-package ` won't even
29
+ try.</em >
25
30
26
31
## Set-up
27
32
Original file line number Diff line number Diff line change @@ -7,10 +7,11 @@ import { getAppRootPath } from "./getAppRootPath"
7
7
import { makePatch } from "./makePatch"
8
8
import { makeRegExp } from "./makeRegExp"
9
9
import { 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"
12
12
import slash = require( "slash" )
13
13
import isCi from "is-ci"
14
+ import { existsSync } from "fs"
14
15
15
16
const appPath = getAppRootPath ( )
16
17
const argv = minimist ( process . argv . slice ( 2 ) , {
@@ -33,6 +34,16 @@ console.log(
33
34
require ( join ( __dirname , "../package.json" ) ) . version ,
34
35
)
35
36
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
+
36
47
if ( argv . version || argv . v ) {
37
48
// noop
38
49
} else if ( argv . help || argv . h ) {
You can’t perform that action at this time.
0 commit comments