Skip to content

Commit 938bf9e

Browse files
committed
refactor: move concrete file removal logic into it's own function
1 parent 73524b9 commit 938bf9e

File tree

2 files changed

+24
-11
lines changed

2 files changed

+24
-11
lines changed

packages/runtime/src/helpers/files.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,26 @@ import { cpus } from 'os'
22

33
import type { NetlifyConfig } from '@netlify/build'
44
import { yellowBright } from 'chalk'
5-
import { existsSync, readJson, move, copy, writeJson, readFile, writeFile, ensureDir, readFileSync } from 'fs-extra'
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'
617
import globby from 'globby'
718
import { PrerenderManifest } from 'next/dist/build'
819
import { outdent } from 'outdent'
920
import pLimit from 'p-limit'
1021
import { join, resolve, dirname } from 'pathe'
1122
import slash from 'slash'
1223

13-
import { MINIMUM_REVALIDATE_SECONDS, DIVIDER } from '../constants'
24+
import { MINIMUM_REVALIDATE_SECONDS, DIVIDER, HIDDEN_PATHS } from '../constants'
1425

1526
import { NextConfig } from './config'
1627
import { loadPrerenderManifest } from './edge'
@@ -467,3 +478,10 @@ export const movePublicFiles = async ({
467478
await copy(publicDir, `${publish}${basePath}/`)
468479
}
469480
}
481+
482+
export const removeMetadataFiles = async (publish: string) => {
483+
for (const HIDDEN_PATH of HIDDEN_PATHS) {
484+
const pathToDelete = join(publish, HIDDEN_PATH)
485+
await remove(pathToDelete)
486+
}
487+
}

packages/runtime/src/index.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import { join, relative } from 'path'
33
import type { NetlifyPlugin, NetlifyPluginOptions } from '@netlify/build'
44
import { bold, redBright } from 'chalk'
55
import destr from 'destr'
6-
import { existsSync, readFileSync, remove } from 'fs-extra'
6+
import { existsSync, readFileSync } from 'fs-extra'
77
import { outdent } from 'outdent'
88

9-
import { HANDLER_FUNCTION_NAME, ODB_FUNCTION_NAME, HIDDEN_PATHS } from './constants'
9+
import { HANDLER_FUNCTION_NAME, ODB_FUNCTION_NAME } from './constants'
1010
import { restoreCache, saveCache } from './helpers/cache'
1111
import {
1212
getNextConfig,
@@ -17,7 +17,7 @@ import {
1717
} from './helpers/config'
1818
import { onPreDev } from './helpers/dev'
1919
import { writeEdgeFunctions, loadMiddlewareManifest, cleanupEdgeFunctions } from './helpers/edge'
20-
import { moveStaticPages, movePublicFiles, patchNextFiles } from './helpers/files'
20+
import { moveStaticPages, movePublicFiles, patchNextFiles, removeMetadataFiles } from './helpers/files'
2121
import { splitApiRoutes } from './helpers/flags'
2222
import {
2323
generateFunctions,
@@ -254,12 +254,7 @@ const plugin: NetlifyPlugin = {
254254
warnForProblematicUserRewrites({ basePath, redirects })
255255
warnForRootRedirects({ appDir })
256256
await warnOnApiRoutes({ FUNCTIONS_DIST })
257-
258-
for (const HIDDEN_PATH of HIDDEN_PATHS) {
259-
const pathToDelete = join(publish, HIDDEN_PATH)
260-
console.log({ pathToDelete })
261-
await remove(pathToDelete)
262-
}
257+
await removeMetadataFiles(publish)
263258

264259
if (experimental?.appDir) {
265260
console.log(

0 commit comments

Comments
 (0)