chore: add debug logging for cache misses in git timestamp retrieval

pull/4958/head
Divyansh Singh 5 days ago
parent 09cf7271fb
commit 6e8239a6e2

@ -1,8 +1,10 @@
import { spawn, sync } from 'cross-spawn' import { spawn, sync } from 'cross-spawn'
import _debug from 'debug'
import fs from 'node:fs' import fs from 'node:fs'
import path from 'node:path' import path from 'node:path'
import { slash } from '../shared' import { slash } from '../shared'
const debug = _debug('vitepress:git')
const cache = new Map<string, number>() const cache = new Map<string, number>()
const RS = 0x1e const RS = 0x1e
@ -91,9 +93,11 @@ export async function cacheAllGitTimestamps(
export async function getGitTimestamp(file: string): Promise<number> { export async function getGitTimestamp(file: string): Promise<number> {
const cached = cache.get(file) const cached = cache.get(file)
// most likely will never be stale except for recently added files in dev
if (cached) return cached 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 if (!fs.existsSync(file)) return 0
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {

Loading…
Cancel
Save