diff --git a/src/node/utils/getGitTimestamp.ts b/src/node/utils/getGitTimestamp.ts index 463379b5..fd6d3177 100644 --- a/src/node/utils/getGitTimestamp.ts +++ b/src/node/utils/getGitTimestamp.ts @@ -1,8 +1,10 @@ import { spawn, sync } from 'cross-spawn' +import _debug from 'debug' import fs from 'node:fs' import path from 'node:path' import { slash } from '../shared' +const debug = _debug('vitepress:git') const cache = new Map() const RS = 0x1e @@ -91,9 +93,11 @@ export async function cacheAllGitTimestamps( export async function getGitTimestamp(file: string): Promise { const cached = cache.get(file) - // most likely will never be stale except for recently added files in dev if (cached) return cached + // most likely will never happen except for recently added files in dev + debug(`[cache miss] ${file}`) + if (!fs.existsSync(file)) return 0 return new Promise((resolve, reject) => {