fix(auto-updater): handle bun.lockb and add workspace validation

- Support binary bun.lockb format by deleting entire file (cannot parse)
- Add workspace check: verify package.json exists before bun install
- Quote paths in error messages for Windows/paths with spaces
This commit is contained in:
acamq
2026-03-08 09:15:13 -06:00
parent f89cc969ec
commit c4112f80db
3 changed files with 45 additions and 14 deletions
+6 -2
View File
@@ -1,4 +1,5 @@
import { beforeEach, afterEach, describe, expect, it, mock, spyOn } from "bun:test"
import { beforeEach, afterEach, describe, expect, it, spyOn } from "bun:test"
import * as fs from "node:fs"
import * as dataPath from "../../shared/data-path"
import * as logger from "../../shared/logger"
import * as spawnHelpers from "../../shared/spawn-with-windows-hide"
@@ -8,6 +9,7 @@ describe("runBunInstallWithDetails", () => {
let getOpenCodeCacheDirSpy: ReturnType<typeof spyOn>
let logSpy: ReturnType<typeof spyOn>
let spawnWithWindowsHideSpy: ReturnType<typeof spyOn>
let existsSyncSpy: ReturnType<typeof spyOn>
beforeEach(() => {
getOpenCodeCacheDirSpy = spyOn(dataPath, "getOpenCodeCacheDir").mockReturnValue("/tmp/opencode-cache")
@@ -15,14 +17,16 @@ describe("runBunInstallWithDetails", () => {
spawnWithWindowsHideSpy = spyOn(spawnHelpers, "spawnWithWindowsHide").mockReturnValue({
exited: Promise.resolve(0),
exitCode: 0,
kill: mock(() => {}),
kill: () => {},
} as ReturnType<typeof spawnHelpers.spawnWithWindowsHide>)
existsSyncSpy = spyOn(fs, "existsSync").mockReturnValue(true)
})
afterEach(() => {
getOpenCodeCacheDirSpy.mockRestore()
logSpy.mockRestore()
spawnWithWindowsHideSpy.mockRestore()
existsSyncSpy.mockRestore()
})
it("runs bun install in the OpenCode cache directory", async () => {