mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2026-04-28 11:17:38 +02:00
added commit date to p2p info
This commit is contained in:
+13
-4
@@ -37,7 +37,7 @@ export default {
|
||||
renameFile: renameFile,
|
||||
deleteDir: deleteDir,
|
||||
formatBytes: formatBytes,
|
||||
getGitRevision: getGitRevision,
|
||||
getGitInfo: getGitInfo,
|
||||
getScriptVersion: getScriptVersion,
|
||||
}
|
||||
|
||||
@@ -314,17 +314,26 @@ function formatBytes(number: number, unit: 'MB' | 'GB' = 'MB'): string {
|
||||
return `${number} byte`
|
||||
}
|
||||
|
||||
function getGitRevision(dir: string): string {
|
||||
function getGitInfo(dir: string): { lastCommitDate: number; revision: string } {
|
||||
try {
|
||||
return child_process
|
||||
const revision = child_process
|
||||
.execSync('git rev-parse HEAD', {
|
||||
cwd: dir,
|
||||
stdio: [0, 'pipe', null],
|
||||
})
|
||||
.toString()
|
||||
.trim()
|
||||
const lastCommitDate = child_process
|
||||
.execSync(`git show -s --format=%ct ${revision}`, {
|
||||
cwd: dir,
|
||||
stdio: [0, 'pipe', null],
|
||||
})
|
||||
.toString()
|
||||
.trim()
|
||||
|
||||
return { lastCommitDate: +lastCommitDate, revision: revision }
|
||||
} catch (e) {
|
||||
return 'Failed to get revision'
|
||||
return { lastCommitDate: 0, revision: 'Failed to get revision' }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user