File tree Expand file tree Collapse file tree 4 files changed +1438
-1310
lines changed Expand file tree Collapse file tree 4 files changed +1438
-1310
lines changed Original file line number Diff line number Diff line change @@ -229,6 +229,10 @@ Run `patch-package` without arguments to apply all patches in your project.
229
229
230
230
Specify the name for the directory in which the patch files are located
231
231
232
+ - ` --expect-patch`
233
+
234
+ Prints error when no patches happen. Best combined with `--error-on-fail` (enabled by default on CI).
235
+
232
236
# ### Notes
233
237
234
238
To apply patches individually, you may use `git` :
Original file line number Diff line number Diff line change @@ -95,28 +95,34 @@ export function applyPatchesForApp({
95
95
appPath,
96
96
reverse,
97
97
patchDir,
98
+ expectPatch,
98
99
shouldExitWithError,
99
100
shouldExitWithWarning,
100
101
bestEffort,
101
102
} : {
102
103
appPath : string
103
104
reverse : boolean
104
105
patchDir : string
106
+ expectPatch : boolean
105
107
shouldExitWithError : boolean
106
108
shouldExitWithWarning : boolean
107
109
bestEffort : boolean
108
110
} ) : void {
109
111
const patchesDirectory = join ( appPath , patchDir )
110
112
const groupedPatches = getGroupedPatches ( patchesDirectory )
111
113
112
- if ( groupedPatches . numPatchFiles === 0 ) {
113
- console . log ( chalk . blueBright ( "No patch files found" ) )
114
- return
115
- }
116
-
117
114
const errors : string [ ] = [ ]
118
115
const warnings : string [ ] = [ ...groupedPatches . warnings ]
119
116
117
+ if ( groupedPatches . numPatchFiles === 0 ) {
118
+ if ( expectPatch ) {
119
+ errors . push ( "No patch files found" )
120
+ } else {
121
+ console . log ( chalk . blueBright ( "No patch files found" ) )
122
+ return
123
+ }
124
+ }
125
+
120
126
for ( const patches of Object . values (
121
127
groupedPatches . pathSpecifierToPatchFiles ,
122
128
) ) {
Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ const argv = minimist(process.argv.slice(2), {
25
25
"error-on-warn" ,
26
26
"create-issue" ,
27
27
"partial" ,
28
+ "expect-patch" ,
28
29
"" ,
29
30
] ,
30
31
string : [ "patch-dir" , "append" , "rebase" ] ,
@@ -114,11 +115,13 @@ if (argv.version || argv.v) {
114
115
process . env . NODE_ENV === "test"
115
116
116
117
const shouldExitWithWarning = ! ! argv [ "error-on-warn" ]
118
+ const expectPatch = ! ! argv [ "expect-patch" ]
117
119
118
120
applyPatchesForApp ( {
119
121
appPath,
120
122
reverse,
121
123
patchDir,
124
+ expectPatch,
122
125
shouldExitWithError,
123
126
shouldExitWithWarning,
124
127
bestEffort : argv . partial ,
@@ -177,6 +180,15 @@ Usage:
177
180
This option was added to help people using CircleCI avoid an issue around caching
178
181
and patch file updates (https://github.com/ds300/patch-package/issues/37),
179
182
but might be useful in other contexts too.
183
+
184
+ ${ chalk . bold ( "--expect-patch" ) }
185
+
186
+ Prints an error if no patch files were found.
187
+
188
+ This option works in tandem with ${ chalk . bold (
189
+ "--error-on-fail" ,
190
+ ) } (enabled by default in CI) to prevent
191
+ accidental skips due to patch folder was missed or ignored. For example during COPY in Dockerfile, or in .dockerignore.
180
192
181
193
182
194
2. Creating patch files
You can’t perform that action at this time.
0 commit comments