@@ -2,18 +2,7 @@ import { cpus } from 'os'
2
2
3
3
import type { NetlifyConfig } from '@netlify/build'
4
4
import { yellowBright } from 'chalk'
5
- import {
6
- existsSync ,
7
- readJson ,
8
- move ,
9
- copy ,
10
- writeJson ,
11
- readFile ,
12
- writeFile ,
13
- ensureDir ,
14
- readFileSync ,
15
- remove ,
16
- } from 'fs-extra'
5
+ import { existsSync , readJson , move , copy , writeJson , ensureDir , readFileSync , remove } from 'fs-extra'
17
6
import globby from 'globby'
18
7
import { PrerenderManifest } from 'next/dist/build'
19
8
import { outdent } from 'outdent'
@@ -297,45 +286,6 @@ export const moveStaticPages = async ({
297
286
}
298
287
}
299
288
300
- const PATCH_WARNING = `/* File patched by Netlify */`
301
-
302
- /**
303
- * Attempt to patch a source file, preserving a backup
304
- */
305
- const patchFile = async ( {
306
- file,
307
- replacements,
308
- } : {
309
- file : string
310
- replacements : Array < [ from : string , to : string ] >
311
- } ) : Promise < boolean > => {
312
- if ( ! existsSync ( file ) ) {
313
- console . warn ( 'File was not found' )
314
- return false
315
- }
316
- let content = await readFile ( file , 'utf8' )
317
-
318
- // If the file has already been patched, patch the backed-up original instead
319
- if ( content . includes ( PATCH_WARNING ) && existsSync ( `${ file } .orig` ) ) {
320
- content = await readFile ( `${ file } .orig` , 'utf8' )
321
- }
322
-
323
- const newContent = replacements . reduce ( ( acc , [ from , to ] ) => {
324
- if ( acc . includes ( to ) ) {
325
- console . log ( 'Already patched. Skipping.' )
326
- return acc
327
- }
328
- return acc . replace ( from , to )
329
- } , content )
330
- if ( newContent === content ) {
331
- console . warn ( 'File was not changed' )
332
- return false
333
- }
334
- await writeFile ( `${ file } .orig` , content )
335
- await writeFile ( file , `${ newContent } \n${ PATCH_WARNING } ` )
336
- console . log ( 'Done' )
337
- return true
338
- }
339
289
/**
340
290
* The file we need has moved around a bit over the past few versions,
341
291
* so we iterate through the options until we find it
0 commit comments