Skip to content

Commit ebe0760

Browse files
committed
fix: Exiting Quartz due to a fatal error: EBUSY: resource busy or locked, rmdir 'public
Fixes #2138
1 parent 52460f3 commit ebe0760

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

quartz/build.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import sourceMapSupport from "source-map-support"
22
sourceMapSupport.install(options)
33
import path from "path"
44
import { PerfTimer } from "./util/perf"
5-
import { rm } from "fs/promises"
5+
import { readdir, rm } from "fs/promises"
6+
import { join } from "path"
67
import { GlobbyFilterFunction, isGitIgnored } from "globby"
78
import { styleText } from "util"
89
import { parseMarkdown } from "./processors/parse"
@@ -42,6 +43,13 @@ type BuildData = {
4243
lastBuildMs: number
4344
}
4445

46+
async function clearDir(dir: string) {
47+
const files = await readdir(dir)
48+
for (const file of files) {
49+
await rm(join(dir, file), { recursive: true, force: true })
50+
}
51+
}
52+
4553
async function buildQuartz(argv: Argv, mut: Mutex, clientRefresh: () => void) {
4654
const ctx: BuildCtx = {
4755
buildId: randomIdNonSecure(),
@@ -67,7 +75,7 @@ async function buildQuartz(argv: Argv, mut: Mutex, clientRefresh: () => void) {
6775

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

7381
perf.addEvent("glob")

0 commit comments

Comments
 (0)