tongong.net

personal website
git clone https://tongong.net/git/tongong.net.git
Log | Files | Refs

commit d0c5e38c48f589a080cc503f5b627d17629aab44
parent b8cc84b8a5bb8c4683e38bc7232f6017f8d45a94
Author: tongong <tongong@gmx.net>
Date:   Mon, 19 Dec 2022 16:40:48 +0100

git build optimizations

Diffstat:
Mgit/.gitignore | 1+
Mgit/build.js | 19++++++++++++++++---
2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/git/.gitignore b/git/.gitignore @@ -1,2 +1,3 @@ repo/* dist/* +tacker-cache.json diff --git a/git/build.js b/git/build.js @@ -44,6 +44,15 @@ fs.writeFileSync("dist/index.html", // include dist in website dist // tacker is used to include logo.png and style.css +// tacker outputs are cached for speed, known files are saved in +// tacker-cache.json +function sha256(filepath) { + return child_process.execSync("sha256sum \"" + filepath + "\"") + .toString().slice(0, -1); +} +// array of known hash-filename combinations +let cached = fs.existsSync("tacker-cache.json")? + JSON.parse(fs.readFileSync("tacker-cache.json").toString()) : []; child_process.execSync("find dist -name *.html") .toString().split("\n").filter(f => f != "").map(f => { // tacker base path @@ -51,10 +60,14 @@ child_process.execSync("find dist -name *.html") f.split("/").slice(0, 2).join("/"); const distpath = f.replace("dist/", "../dist/git/"); const distparent = distpath.split("/").slice(0, -1).join("/"); - fs.mkdirSync(distparent, {recursive: true}); - child_process.execSync("tacker -p \"" + basepath - + "\" \"" + f + "\" \"" + distpath + "\""); + if (!cached.includes(sha256(f))) { + fs.mkdirSync(distparent, {recursive: true}); + child_process.execSync("tacker -p \"" + basepath + + "\" \"" + f + "\" \"" + distpath + "\""); + cached.push(sha256(f)); + } }); +fs.writeFileSync("tacker-cache.json", JSON.stringify(cached)); // create directories for git https clone repositories.forEach(r => {