Fixing commit in build

This commit is contained in:
Jean Ouina 2020-06-13 07:37:58 +02:00
parent 93a735193b
commit 8009c6a2ed
2 changed files with 8 additions and 2 deletions

View File

@ -53,7 +53,7 @@ async function main(){
if(filepath.endsWith("git.js")){
let commit = child_process.execSync("git rev-parse HEAD").toString()
console.info(`Obtained commit ${commit} for the compilation`)
await fs.promises.writeFile(newpath, terser.minify((await fs.promises.readFile(filepath, "utf8")).replace("{commit}", commit)).code, "utf8")
await fs.promises.writeFile(newpath, terser.minify(fs.readFileSync(filepath, "utf8").replace(/"{commit}"/g, `"${commit.split("\n")[0]}"`)).code, "utf8")
}else{
await fs.promises.writeFile(newpath, terser.minify(await fs.promises.readFile(filepath, "utf8")).code, "utf8")
}

View File

@ -1,8 +1,14 @@
import * as child_process from "child_process"
let commit_id = "{commit}"
const defaultString = Buffer.from([
123, 99, 111,
109, 109, 105,
116, 125
]).toString("utf8")
export function getCommitID(){
if(commit_id === "{" + "commit}"){
if(commit_id === defaultString){
try{
return commit_id = child_process.execSync("git rev-parse HEAD").toString()
}catch(e){