mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-19 10:54:06 -06:00
fix: Exiting Quartz due to a fatal error: EBUSY: resource busy or locked, rmdir 'public
Fixes #2138
This commit is contained in:
parent
52460f376f
commit
7356245d49
@ -2,7 +2,8 @@ import sourceMapSupport from "source-map-support"
|
|||||||
sourceMapSupport.install(options)
|
sourceMapSupport.install(options)
|
||||||
import path from "path"
|
import path from "path"
|
||||||
import { PerfTimer } from "./util/perf"
|
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 { GlobbyFilterFunction, isGitIgnored } from "globby"
|
||||||
import { styleText } from "util"
|
import { styleText } from "util"
|
||||||
import { parseMarkdown } from "./processors/parse"
|
import { parseMarkdown } from "./processors/parse"
|
||||||
@ -42,6 +43,19 @@ type BuildData = {
|
|||||||
lastBuildMs: number
|
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 })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function buildQuartz(argv: Argv, mut: Mutex, clientRefresh: () => void) {
|
async function buildQuartz(argv: Argv, mut: Mutex, clientRefresh: () => void) {
|
||||||
const ctx: BuildCtx = {
|
const ctx: BuildCtx = {
|
||||||
buildId: randomIdNonSecure(),
|
buildId: randomIdNonSecure(),
|
||||||
@ -67,7 +81,7 @@ async function buildQuartz(argv: Argv, mut: Mutex, clientRefresh: () => void) {
|
|||||||
|
|
||||||
const release = await mut.acquire()
|
const release = await mut.acquire()
|
||||||
perf.addEvent("clean")
|
perf.addEvent("clean")
|
||||||
await rm(output, { recursive: true, force: true })
|
await clearDir(output)
|
||||||
console.log(`Cleaned output directory \`${output}\` in ${perf.timeSince("clean")}`)
|
console.log(`Cleaned output directory \`${output}\` in ${perf.timeSince("clean")}`)
|
||||||
|
|
||||||
perf.addEvent("glob")
|
perf.addEvent("glob")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user