Move toRebuild and toRemove inside rebuild func

This commit is contained in:
Kabir Khandpur 2024-01-18 17:21:50 +00:00
parent 26ed8db142
commit 8c4dbb13c7

View File

@ -24,8 +24,6 @@ type BuildData = {
mut: Mutex mut: Mutex
initialSlugs: FullSlug[] initialSlugs: FullSlug[]
contentMap: Map<FilePath, ProcessedContent> contentMap: Map<FilePath, ProcessedContent>
toRebuild: Set<FilePath>
toRemove: Set<FilePath>
trackedAssets: Set<FilePath> trackedAssets: Set<FilePath>
lastBuildMs: number lastBuildMs: number
} }
@ -97,8 +95,6 @@ async function startServing(
contentMap, contentMap,
ignored: await isGitIgnored(), ignored: await isGitIgnored(),
initialSlugs: ctx.allSlugs, initialSlugs: ctx.allSlugs,
toRebuild: new Set<FilePath>(),
toRemove: new Set<FilePath>(),
trackedAssets: new Set<FilePath>(), trackedAssets: new Set<FilePath>(),
lastBuildMs: 0, lastBuildMs: 0,
} }
@ -125,20 +121,13 @@ async function rebuild(
clientRefresh: () => void, clientRefresh: () => void,
buildData: BuildData, // note: this function mutates buildData buildData: BuildData, // note: this function mutates buildData
) { ) {
const { const { ctx, ignored, mut, initialSlugs, contentMap, trackedAssets, lastBuildMs } = buildData
ctx,
ignored,
mut,
initialSlugs,
contentMap,
toRebuild,
toRemove,
trackedAssets,
lastBuildMs,
} = buildData
const { argv } = ctx const { argv } = ctx
const toRebuild = new Set<FilePath>()
const toRemove = new Set<FilePath>()
// don't do anything for gitignored files // don't do anything for gitignored files
if (ignored(fp)) { if (ignored(fp)) {
return return
@ -210,8 +199,6 @@ async function rebuild(
release() release()
clientRefresh() clientRefresh()
toRebuild.clear()
toRemove.clear()
} }
export default async (argv: Argv, mut: Mutex, clientRefresh: () => void) => { export default async (argv: Argv, mut: Mutex, clientRefresh: () => void) => {