feat: include commit hash in bare-mux builds

This commit is contained in:
Percs 2024-10-13 15:57:22 -05:00
parent 3fc18f1cf4
commit 98aae5c46c
3 changed files with 17 additions and 3 deletions

View file

@ -1,6 +1,8 @@
import replace from '@rollup/plugin-replace';
import terser from '@rollup/plugin-terser';
import typescript from 'rollup-plugin-typescript2';
import { execSync } from "node:child_process";
import { readFile } from 'node:fs/promises';
import { fileURLToPath } from 'node:url';
@ -13,8 +15,20 @@ const commonPlugins = () => [
'self.BARE_MUX_VERSION': JSON.stringify(
pkg.version
),
}),
'self.BARE_MUX_COMMITHASH': (() => {
try {
let hash = JSON.stringify(
execSync("git rev-parse --short HEAD", {
encoding: "utf-8",
}).replace(/\r?\n|\r/g, "")
);
return hash;
} catch (e) {
return "unknown";
}
})(),
}),
];
const configs = [

View file

@ -11,4 +11,4 @@ export type * from './connection';
export type * from "./snapshot";
//@ts-expect-error this gets filled in
console.debug(`bare-mux: running v${self.BARE_MUX_VERSION}`);
console.debug(`bare-mux: running v${self.BARE_MUX_VERSION} (build ${self.BARE_MUX_COMMITHASH})`);

View file

@ -88,4 +88,4 @@ self.onconnect = (event: MessageEvent) => {
}
//@ts-expect-error this gets filled in
console.debug(`bare-mux: running v${self.BARE_MUX_VERSION}`);
console.debug(`bare-mux: running v${self.BARE_MUX_VERSION} (build ${self.BARE_MUX_COMMITHASH})`);