Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions quartz/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import sourceMapSupport from "source-map-support"
sourceMapSupport.install(options)
import path from "path"
import { PerfTimer } from "./util/perf"
import { rm } from "fs/promises"
import { readdir, rm } from "fs/promises"
import { join } from "path"
import { GlobbyFilterFunction, isGitIgnored } from "globby"
import { styleText } from "util"
import { parseMarkdown } from "./processors/parse"
Expand Down Expand Up @@ -42,6 +43,19 @@ type BuildData = {
lastBuildMs: number
}

async function clearDir(dir: string) {
let files
try {
files = await readdir(dir)
} catch {
return
}

for (const file of files) {
await rm(join(dir, file), { recursive: true, force: true })
}
}
Comment thread
adoyle-h marked this conversation as resolved.

async function buildQuartz(argv: Argv, mut: Mutex, clientRefresh: () => void) {
const ctx: BuildCtx = {
buildId: randomIdNonSecure(),
Expand All @@ -67,7 +81,7 @@ async function buildQuartz(argv: Argv, mut: Mutex, clientRefresh: () => void) {

const release = await mut.acquire()
perf.addEvent("clean")
await rm(output, { recursive: true, force: true })
await clearDir(output)
console.log(`Cleaned output directory \`${output}\` in ${perf.timeSince("clean")}`)

perf.addEvent("glob")
Expand Down