feat: moves getGitDate to a shared utils file
This commit is contained in:
parent
9137556a4a
commit
223bdf525a
4 changed files with 16 additions and 23 deletions
10
apps/blog/src/utils.ts
Normal file
10
apps/blog/src/utils.ts
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import { execSync } from 'node:child_process';
|
||||
|
||||
export function getGitDate(filePath: string): Date {
|
||||
try {
|
||||
const timestamp = execSync(`git log -1 --format=%cI -- "${filePath}"`, { encoding: 'utf8' }).trim();
|
||||
return timestamp ? new Date(timestamp) : new Date(0);
|
||||
} catch {
|
||||
return new Date(0);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue