File tree 2 files changed +11
-4
lines changed
2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -280,6 +280,8 @@ export const moveStaticPages = async ({
280
280
}
281
281
}
282
282
283
+ const PATCH_WARNING = `/* File patched by Netlify */`
284
+
283
285
/**
284
286
* Attempt to patch a source file, preserving a backup
285
287
*/
@@ -294,7 +296,13 @@ const patchFile = async ({
294
296
console . warn ( 'File was not found' )
295
297
return false
296
298
}
297
- const content = await readFile ( file , 'utf8' )
299
+ let content = await readFile ( file , 'utf8' )
300
+
301
+ // If the file has already been patched, patch the backed-up original instead
302
+ if ( content . includes ( PATCH_WARNING ) && existsSync ( `${ file } .orig` ) ) {
303
+ content = await readFile ( `${ file } .orig` , 'utf8' )
304
+ }
305
+
298
306
const newContent = replacements . reduce ( ( acc , [ from , to ] ) => {
299
307
if ( acc . includes ( to ) ) {
300
308
console . log ( 'Already patched. Skipping.' )
@@ -307,7 +315,7 @@ const patchFile = async ({
307
315
return false
308
316
}
309
317
await writeFile ( `${ file } .orig` , content )
310
- await writeFile ( file , newContent )
318
+ await writeFile ( file , ` ${ newContent } \n ${ PATCH_WARNING } ` )
311
319
console . log ( 'Done' )
312
320
return true
313
321
}
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ import {
16
16
generateCustomHeaders ,
17
17
} from './helpers/config'
18
18
import { updateConfig , writeEdgeFunctions , loadMiddlewareManifest } from './helpers/edge'
19
- import { moveStaticPages , movePublicFiles , patchNextFiles , unpatchNextFiles } from './helpers/files'
19
+ import { moveStaticPages , movePublicFiles , patchNextFiles } from './helpers/files'
20
20
import { generateFunctions , setupImageFunction , generatePagesResolver } from './helpers/functions'
21
21
import { generateRedirects , generateStaticRedirects } from './helpers/redirects'
22
22
import { shouldSkip , isNextAuthInstalled , getCustomImageResponseHeaders } from './helpers/utils'
@@ -200,7 +200,6 @@ const plugin: NetlifyPlugin = {
200
200
201
201
warnForProblematicUserRewrites ( { basePath, redirects } )
202
202
warnForRootRedirects ( { appDir } )
203
- await unpatchNextFiles ( basePath )
204
203
} ,
205
204
}
206
205
module . exports = plugin
You can’t perform that action at this time.
0 commit comments