fix(vite): drop trailing or leading whitespace in build id (#3408)

Fixes https://github.com/denoland/fresh/issues/3406
This commit is contained in:
Marvin Hagemeister
2025-09-12 12:33:13 +02:00
committed by GitHub
parent 0e6bddd06e
commit e5bc9194e9
+3 -3
View File
@@ -45,7 +45,7 @@ export async function getBuildId(dev: boolean): Promise<string> {
const gitRevision = Deno.env.get("DENO_DEPLOYMENT_ID") ?? const gitRevision = Deno.env.get("DENO_DEPLOYMENT_ID") ??
Deno.env.get("GITHUB_SHA") ?? Deno.env.get("CI_COMMIT_SHA"); Deno.env.get("GITHUB_SHA") ?? Deno.env.get("CI_COMMIT_SHA");
if (gitRevision !== undefined) { if (gitRevision !== undefined) {
return gitRevision; return gitRevision.trim();
} }
if (!dev) { if (!dev) {
@@ -54,7 +54,7 @@ export async function getBuildId(dev: boolean): Promise<string> {
const res = await new Deno.Command(bin, { args: ["rev-parse", "HEAD"] }) const res = await new Deno.Command(bin, { args: ["rev-parse", "HEAD"] })
.output(); .output();
return new TextDecoder().decode(res.stdout); return new TextDecoder().decode(res.stdout).trim();
} catch { } catch {
// ignore // ignore
} }
@@ -62,5 +62,5 @@ export async function getBuildId(dev: boolean): Promise<string> {
const arr = new Uint32Array(1); const arr = new Uint32Array(1);
crypto.getRandomValues(arr); crypto.getRandomValues(arr);
return String(arr[0]); return String(arr[0]).trim();
} }