From 8009c6a2ed9514b96c2f7a4765ce6203ed23bf5e Mon Sep 17 00:00:00 2001 From: Jean Ouina Date: Sat, 13 Jun 2020 07:37:58 +0200 Subject: [PATCH] Fixing commit in build --- compile.js | 2 +- src/common/git.ts | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/compile.js b/compile.js index 0a9742a..0caa9b2 100644 --- a/compile.js +++ b/compile.js @@ -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") } diff --git a/src/common/git.ts b/src/common/git.ts index 2b84598..b98892b 100644 --- a/src/common/git.ts +++ b/src/common/git.ts @@ -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){