From e56d95e683182b6c7edb5778ace40afebcd9c984 Mon Sep 17 00:00:00 2001 From: Jan Wisgerhof Date: Wed, 17 Jun 2026 17:29:17 +1000 Subject: [PATCH] fix: hide console window when running 'git rev-parse HEAD' on Windows --- packages/bundler-plugins/src/core/utils.ts | 2 +- .../bundler-plugins/test/core/utils.test.ts | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/packages/bundler-plugins/src/core/utils.ts b/packages/bundler-plugins/src/core/utils.ts index 3a24e4ea..6ddb8cec 100644 --- a/packages/bundler-plugins/src/core/utils.ts +++ b/packages/bundler-plugins/src/core/utils.ts @@ -192,7 +192,7 @@ function gitRevision(): string | undefined { let gitRevision: string | undefined; try { gitRevision = childProcess - .execSync("git rev-parse HEAD", { stdio: ["ignore", "pipe", "ignore"] }) + .execSync("git rev-parse HEAD", { stdio: ["ignore", "pipe", "ignore"], windowsHide: true }) .toString() .trim(); } catch { diff --git a/packages/bundler-plugins/test/core/utils.test.ts b/packages/bundler-plugins/test/core/utils.test.ts index e229cccd..1e07612d 100644 --- a/packages/bundler-plugins/test/core/utils.test.ts +++ b/packages/bundler-plugins/test/core/utils.test.ts @@ -1,4 +1,5 @@ import { + determineReleaseName, generateReleaseInjectorCode, generateModuleMetadataInjectorCode, getDependencies, @@ -9,6 +10,7 @@ import { stringToUUID, } from "../../src/core/utils"; +import childProcess from "child_process"; import fs from "fs"; import { describe, it, expect, test, vi } from "vitest"; import path from "node:path"; @@ -293,3 +295,26 @@ describe("serializeIgnoreOptions", () => { expect(result).toEqual([]); }); }); + +describe("determineReleaseName", () => { + it("runs `git rev-parse HEAD` with windowsHide so no console window flashes on Windows", () => { + // Clear env so the function falls through the CI/git-provider checks to the + // git fallback (CI runs with GITHUB_SHA set, which would otherwise short-circuit). + const originalEnv = process.env; + process.env = {}; + const execSyncSpy = vi + .spyOn(childProcess, "execSync") + .mockReturnValue(Buffer.from("0".repeat(40))); + + try { + determineReleaseName(); + expect(execSyncSpy).toHaveBeenCalledWith( + "git rev-parse HEAD", + expect.objectContaining({ windowsHide: true }) + ); + } finally { + process.env = originalEnv; + execSyncSpy.mockRestore(); + } + }); +});