fix(bun-install): default outputMode to "pipe" to prevent TUI stdout leak
runBunInstallWithDetails() defaulted to outputMode:"inherit", causing bun install stdout/stderr to leak into the TUI when callers omitted the option. Changed default to "pipe" so output is captured silently. Also fixed stale mock in background-update-check.test.ts: the test was mocking runBunInstall (unused) instead of runBunInstallWithDetails, and returning boolean instead of BunInstallResult.
This commit is contained in:
@@ -53,8 +53,8 @@ describe("runBunInstallWithDetails", () => {
|
||||
})
|
||||
|
||||
describe("#given the cache workspace exists", () => {
|
||||
describe("#when bun install uses inherited output", () => {
|
||||
it("#then runs bun install in the cache directory", async () => {
|
||||
describe("#when bun install uses default piped output", () => {
|
||||
it("#then pipes stdout and stderr by default", async () => {
|
||||
// given
|
||||
|
||||
// when
|
||||
@@ -65,8 +65,8 @@ describe("runBunInstallWithDetails", () => {
|
||||
expect(getOpenCodeCacheDirSpy).toHaveBeenCalledTimes(1)
|
||||
expect(spawnWithWindowsHideSpy).toHaveBeenCalledWith(["bun", "install"], {
|
||||
cwd: "/tmp/opencode-cache",
|
||||
stdout: "inherit",
|
||||
stderr: "inherit",
|
||||
stdout: "pipe",
|
||||
stderr: "pipe",
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -88,6 +88,23 @@ describe("runBunInstallWithDetails", () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe("#when bun install uses explicit inherited output", () => {
|
||||
it("#then passes inherit mode to the spawned process", async () => {
|
||||
// given
|
||||
|
||||
// when
|
||||
const result = await runBunInstallWithDetails({ outputMode: "inherit" })
|
||||
|
||||
// then
|
||||
expect(result).toEqual({ success: true })
|
||||
expect(spawnWithWindowsHideSpy).toHaveBeenCalledWith(["bun", "install"], {
|
||||
cwd: "/tmp/opencode-cache",
|
||||
stdout: "inherit",
|
||||
stderr: "inherit",
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe("#when piped bun install fails", () => {
|
||||
it("#then logs captured stdout and stderr", async () => {
|
||||
// given
|
||||
|
||||
@@ -64,7 +64,7 @@ function logCapturedOutputOnFailure(outputMode: BunInstallOutputMode, output: Bu
|
||||
}
|
||||
|
||||
export async function runBunInstallWithDetails(options?: RunBunInstallOptions): Promise<BunInstallResult> {
|
||||
const outputMode = options?.outputMode ?? "inherit"
|
||||
const outputMode = options?.outputMode ?? "pipe"
|
||||
const cacheDir = getOpenCodeCacheDir()
|
||||
const packageJsonPath = `${cacheDir}/package.json`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user