Lightcord/src/common/git.ts

21 lines
482 B
TypeScript
Raw Permalink Normal View History

import * as child_process from "child_process"
let commit_id = "{commit}"
2020-06-13 07:37:58 +02:00
const defaultString = Buffer.from([
2020-06-27 21:02:48 +02:00
123, 99, 111,
2020-06-13 07:37:58 +02:00
109, 109, 105,
116, 125
]).toString("utf8")
export function getCommitID(){
2020-06-13 07:37:58 +02:00
if(commit_id === defaultString){
try{
return commit_id = child_process.execSync("git rev-parse HEAD").toString()
}catch(e){
console.error(e)
return "{Unknown}"
}
}else{
return commit_id
}
}