mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-11-24 16:07:24 +08:00
* refactor(utils): use Temporal API * refactor(route): migrate to @/utils/time * fix(route/rfi): use Temporal for duration * style: add oxlint rule for temporal * fix: merge duplicated parse duration * fix: remove duplicated convertDateToISO8601 * fix: remove outdated check * fix: remove fake date
21 lines
670 B
TypeScript
21 lines
670 B
TypeScript
import { execSync } from 'node:child_process';
|
|
|
|
// without git, or outside a repository (as installed from npm), git's complaint is left unprinted
|
|
const git = (command: string) =>
|
|
execSync(command, { stdio: ['ignore', 'pipe', 'ignore'] })
|
|
.toString()
|
|
.trim();
|
|
|
|
let gitHash = process.env.HEROKU_SLUG_COMMIT?.slice(0, 8) || process.env.VERCEL_GIT_COMMIT_SHA?.slice(0, 8);
|
|
let gitDate: Temporal.Instant | undefined;
|
|
if (!gitHash) {
|
|
try {
|
|
gitHash = git('git rev-parse HEAD').slice(0, 8);
|
|
gitDate = Temporal.Instant.from(git('git log -1 --format=%cI'));
|
|
} catch {
|
|
gitHash = 'unknown';
|
|
}
|
|
}
|
|
|
|
export { gitDate, gitHash };
|