@@ -2,7 +2,8 @@ import sourceMapSupport from "source-map-support"
22sourceMapSupport . install ( options )
33import path from "path"
44import { PerfTimer } from "./util/perf"
5- import { rm } from "fs/promises"
5+ import { readdir , rm } from "fs/promises"
6+ import { join } from "path"
67import { GlobbyFilterFunction , isGitIgnored } from "globby"
78import { styleText } from "util"
89import { 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+
4553async 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