mirror of
https://github.com/netbirdio/docs.git
synced 2026-05-12 03:49:52 +00:00
Added auto-generated "Updated..." line under H1 (#719)
This commit is contained in:
18
scripts/git-dates.mjs
Normal file
18
scripts/git-dates.mjs
Normal file
@@ -0,0 +1,18 @@
|
||||
import { execSync } from 'child_process'
|
||||
|
||||
/**
|
||||
* Get the last modified date for a file from git history.
|
||||
* Returns YYYY-MM-DD or null if the file is not tracked / git is unavailable.
|
||||
*/
|
||||
export function getGitLastModified(filePath) {
|
||||
try {
|
||||
const date = execSync(`git log -1 --format=%cI -- "${filePath}"`, {
|
||||
encoding: 'utf-8',
|
||||
stdio: ['pipe', 'pipe', 'ignore'],
|
||||
}).trim()
|
||||
|
||||
return date ? date.split('T')[0] : null
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user