aboutsummaryrefslogtreecommitdiffstats
path: root/build.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-08-18 09:20:17 -0700
committerAdam Soltys <[email protected]>2026-08-18 09:20:17 -0700
commit8e0bf7dc840ecdf6ba991c5e63d4c8304419342d (patch)
treecc1159143c47ba2d5a8520ea3ac44f52d1595292 /build.js
parentca8e5590994eec3c5c4e05eac59f3906ca1a2cdc (diff)
downloadcoinosv3-8e0bf7dc840ecdf6ba991c5e63d4c8304419342d.tar.gz
coinosv3-8e0bf7dc840ecdf6ba991c5e63d4c8304419342d.zip
The footer says what it stamps: the word commit, the short hash git actually knows, and a link to it — the build token stays where it belongs, inside the service worker
Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JtaatFfAbx91Nh3xqKVqKz
Diffstat (limited to 'build.js')
-rw-r--r--build.js14
1 files changed, 13 insertions, 1 deletions
diff --git a/build.js b/build.js
index 0c8cba2..6e1829d 100644
--- a/build.js
+++ b/build.js
@@ -245,6 +245,18 @@ const flagsPlugin = (staging) => ({
},
});
+// The commit this build came from: the deploy hook passes GIT_COMMIT (the
+// worktree it builds in has no .git), local builds ask git directly.
+function gitCommit() {
+ if (process.env.GIT_COMMIT) return process.env.GIT_COMMIT.slice(0, 7);
+ try {
+ const r = Bun.spawnSync(['git', 'rev-parse', '--short', 'HEAD']);
+ const out = r.stdout.toString().trim();
+ if (/^[0-9a-f]{6,}$/.test(out)) return out;
+ } catch {}
+ return 'dev';
+}
+
export async function buildHtml({ minify = true, pwa = minify, features = process.env.HAL_FEATURES, staging = isStaging() } = {}) {
const result = await Bun.build({
entrypoints: ['./src/app.js'],
@@ -276,7 +288,7 @@ ${pwa ? PWA_HEAD : ''}<style>${css}</style>
<div id="app"></div>
<script>${js}</script>
${pwa ? SW_REGISTER + '\n' : ''}</body>
-</html>`;
+</html>`.replaceAll('{{COMMIT}}', gitCommit());
}
if (import.meta.main) {