readGitLastUpdated #
Reads the last commit time (milliseconds) of every file under the site root in one git log call, keyed by absolute path. Returns undefined with a warning outside a git repository or in a shallow clone, where the dates would be wrong.
Usage #
TypeScript
import { readGitLastUpdated } from 'kawapress/generator'
const times = await readGitLastUpdated('/site', {
label: 'My Plugin',
skipped: 'lastmod',
})Parameters
siteRootstring
Absolute path of the site root.
optionsReadGitLastUpdatedOptions
Names the caller for the warning.
labelstring
Prefix of the warning, naming the caller, e.g. KawaPress Sitemap.
skippedstring
What the caller skips when git history is unavailable, e.g. lastmod.
Returns Last commit times by absolute path, or undefined when git history is unavailable.
Full type signature
TypeScript
function readGitLastUpdated(
siteRoot: string,
options: ReadGitLastUpdatedOptions,
): Promise<Map<string, number> | undefined>

Comments