2020-06-10 21:01:33 +02:00
|
|
|
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")
|
2020-06-10 21:01:33 +02:00
|
|
|
export function getCommitID(){
|
2020-06-13 07:37:58 +02:00
|
|
|
if(commit_id === defaultString){
|
2020-06-10 21:01:33 +02:00
|
|
|
try{
|
|
|
|
return commit_id = child_process.execSync("git rev-parse HEAD").toString()
|
|
|
|
}catch(e){
|
|
|
|
console.error(e)
|
|
|
|
return "{Unknown}"
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
return commit_id
|
|
|
|
}
|
|
|
|
}
|