@@ -38,8 +38,13 @@ type BuildData = {
38
38
39
39
type FileEvent = "add" | "change" | "delete"
40
40
41
+ function newBuildId ( ) {
42
+ return new Date ( ) . toISOString ( )
43
+ }
44
+
41
45
async function buildQuartz ( argv : Argv , mut : Mutex , clientRefresh : ( ) => void ) {
42
46
const ctx : BuildCtx = {
47
+ buildId : newBuildId ( ) ,
43
48
argv,
44
49
cfg,
45
50
allSlugs : [ ] ,
@@ -167,6 +172,7 @@ async function partialRebuildFromEntrypoint(
167
172
168
173
const perf = new PerfTimer ( )
169
174
console . log ( chalk . yellow ( "Detected change, rebuilding..." ) )
175
+ ctx . buildId = newBuildId ( )
170
176
171
177
// UPDATE DEP GRAPH
172
178
const fp = joinSegments ( argv . directory , toPosixPath ( filepath ) ) as FilePath
@@ -363,14 +369,10 @@ async function rebuildFromEntrypoint(
363
369
364
370
const perf = new PerfTimer ( )
365
371
console . log ( chalk . yellow ( "Detected change, rebuilding..." ) )
372
+ ctx . buildId = newBuildId ( )
373
+
366
374
try {
367
375
const filesToRebuild = [ ...toRebuild ] . filter ( ( fp ) => ! toRemove . has ( fp ) )
368
-
369
- const trackedSlugs = [ ...new Set ( [ ...contentMap . keys ( ) , ...toRebuild , ...trackedAssets ] ) ]
370
- . filter ( ( fp ) => ! toRemove . has ( fp ) )
371
- . map ( ( fp ) => slugifyFilePath ( path . posix . relative ( argv . directory , fp ) as FilePath ) )
372
-
373
- ctx . allSlugs = [ ...new Set ( [ ...initialSlugs , ...trackedSlugs ] ) ]
374
376
const parsedContent = await parseMarkdown ( ctx , filesToRebuild )
375
377
for ( const content of parsedContent ) {
376
378
const [ _tree , vfile ] = content
@@ -384,6 +386,13 @@ async function rebuildFromEntrypoint(
384
386
const parsedFiles = [ ...contentMap . values ( ) ]
385
387
const filteredContent = filterContent ( ctx , parsedFiles )
386
388
389
+ // re-update slugs
390
+ const trackedSlugs = [ ...new Set ( [ ...contentMap . keys ( ) , ...toRebuild , ...trackedAssets ] ) ]
391
+ . filter ( ( fp ) => ! toRemove . has ( fp ) )
392
+ . map ( ( fp ) => slugifyFilePath ( path . posix . relative ( argv . directory , fp ) as FilePath ) )
393
+
394
+ ctx . allSlugs = [ ...new Set ( [ ...initialSlugs , ...trackedSlugs ] ) ]
395
+
387
396
// TODO: we can probably traverse the link graph to figure out what's safe to delete here
388
397
// instead of just deleting everything
389
398
await rimraf ( path . join ( argv . output , ".*" ) , { glob : true } )
0 commit comments