Skip to content

Commit

Permalink
include build number in error screen
Browse files Browse the repository at this point in the history
  • Loading branch information
Percslol committed Oct 13, 2024
1 parent b78de17 commit aa3a176
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
14 changes: 14 additions & 0 deletions build.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { rimraf } from 'rimraf';
import { copyFile, mkdir, readFile, writeFile } from 'node:fs/promises';
import { build } from 'esbuild';
import { execSync } from "node:child_process";

// read version from package.json
const pkg = JSON.parse(await readFile('package.json'));
Expand Down Expand Up @@ -29,6 +30,19 @@ let builder = await build({
'process.env.ULTRAVIOLET_VERSION': JSON.stringify(
process.env.ULTRAVIOLET_VERSION
),
'process.env.ULTRAVIOLET_COMMIT_HASH': (() => {
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";
}
})(),
},
bundle: true,
treeShaking: true,
Expand Down
5 changes: 4 additions & 1 deletion src/uv.sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,9 @@ function errorTemplate(
uvVersion.textContent = ${JSON.stringify(
process.env.ULTRAVIOLET_VERSION
)};
uvBuild.textContent = ${JSON.stringify(
process.env.ULTRAVIOLET_COMMIT_HASH
)};
`

return (
Expand Down Expand Up @@ -476,7 +479,7 @@ function errorTemplate(
</ul>
<button id="reload">Reload</button>
<hr />
<p><i>Ultraviolet v<span id="uvVersion"></span></i></p>
<p><i>Ultraviolet v<span id="uvVersion"></span> (build <span id="uvBuild"></span>)</i></p>
<script src="${
'data:application/javascript,' + encodeURIComponent(script)
}"></script>
Expand Down

0 comments on commit aa3a176

Please sign in to comment.