mirror of
https://github.com/zoriya/v10.git
synced 2026-08-16 02:45:09 +00:00
chore(site): rename website to site
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import { simpleGit } from 'simple-git';
|
||||
|
||||
/**
|
||||
* Git service interface for dependency injection (testability).
|
||||
*/
|
||||
export interface GitService {
|
||||
getLastModifiedDate: (filePath: string) => Promise<Date | null>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a git service instance using simple-git.
|
||||
*/
|
||||
export function createGitService(): GitService {
|
||||
const git = simpleGit();
|
||||
|
||||
return {
|
||||
async getLastModifiedDate(filePath: string): Promise<Date | null> {
|
||||
try {
|
||||
const log = await git.log({ file: filePath, maxCount: 1 });
|
||||
if (!log.latest) return null;
|
||||
|
||||
return new Date(log.latest.date);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Default git service instance for production use.
|
||||
*/
|
||||
export const defaultGitService = createGitService();
|
||||
Reference in New Issue
Block a user