summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDax <[email protected]>2026-02-18 12:38:30 -0500
committerGitHub <[email protected]>2026-02-18 12:38:30 -0500
commitc88ff3c08b508da1c3f473d1a4ffc883df7b65f8 (patch)
treebb180b70c840eba240a0e52053eacc8b0416b425
parente0e8b94384c3df20fd56a8754383a7b52cbd0240 (diff)
downloadopencode-c88ff3c08b508da1c3f473d1a4ffc883df7b65f8.tar.gz
opencode-c88ff3c08b508da1c3f473d1a4ffc883df7b65f8.zip
refactor: migrate src/bun/index.ts from Bun.file()/Bun.write() to Filesystem module (#14147)
-rw-r--r--packages/opencode/src/bun/index.ts19
1 files changed, 10 insertions, 9 deletions
diff --git a/packages/opencode/src/bun/index.ts b/packages/opencode/src/bun/index.ts
index bdb7cff78..79aaae2bc 100644
--- a/packages/opencode/src/bun/index.ts
+++ b/packages/opencode/src/bun/index.ts
@@ -66,14 +66,14 @@ export namespace BunProc {
using _ = await Lock.write("bun-install")
const mod = path.join(Global.Path.cache, "node_modules", pkg)
- const pkgjson = Bun.file(path.join(Global.Path.cache, "package.json"))
- const parsed = await pkgjson.json().catch(async () => {
- const result = { dependencies: {} }
- await Bun.write(pkgjson.name!, JSON.stringify(result, null, 2))
+ const pkgjsonPath = path.join(Global.Path.cache, "package.json")
+ const parsed = await Filesystem.readJson<{ dependencies: Record<string, string> }>(pkgjsonPath).catch(async () => {
+ const result = { dependencies: {} as Record<string, string> }
+ await Filesystem.writeJson(pkgjsonPath, result)
return result
})
- const dependencies = parsed.dependencies ?? {}
- if (!parsed.dependencies) parsed.dependencies = dependencies
+ if (!parsed.dependencies) parsed.dependencies = {} as Record<string, string>
+ const dependencies = parsed.dependencies
const modExists = await Filesystem.exists(mod)
const cachedVersion = dependencies[pkg]
@@ -123,15 +123,16 @@ export namespace BunProc {
// This ensures subsequent starts use the cached version until explicitly updated
let resolvedVersion = version
if (version === "latest") {
- const installedPkgJson = Bun.file(path.join(mod, "package.json"))
- const installedPkg = await installedPkgJson.json().catch(() => null)
+ const installedPkg = await Filesystem.readJson<{ version?: string }>(path.join(mod, "package.json")).catch(
+ () => null,
+ )
if (installedPkg?.version) {
resolvedVersion = installedPkg.version
}
}
parsed.dependencies[pkg] = resolvedVersion
- await Bun.write(pkgjson.name!, JSON.stringify(parsed, null, 2))
+ await Filesystem.writeJson(pkgjsonPath, parsed)
return mod
}
}