summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDax <[email protected]>2026-02-18 16:13:50 -0500
committerGitHub <[email protected]>2026-02-18 16:13:50 -0500
commit3cde93bf2decbebf9869cfbe9e8f6e960ca9ac86 (patch)
treeaea5d443ea2e5a09b4dbb7cb7a8773c171ca801c
parent898bcdec870c1c9c1ea6f3bea9af5bc8616ac5cd (diff)
downloadopencode-3cde93bf2decbebf9869cfbe9e8f6e960ca9ac86.tar.gz
opencode-3cde93bf2decbebf9869cfbe9e8f6e960ca9ac86.zip
refactor: migrate src/auth/index.ts from Bun.file()/Bun.write() to Filesystem module (#14140)
-rw-r--r--packages/opencode/src/auth/index.ts10
1 files changed, 4 insertions, 6 deletions
diff --git a/packages/opencode/src/auth/index.ts b/packages/opencode/src/auth/index.ts
index ce948b92a..776cc99b4 100644
--- a/packages/opencode/src/auth/index.ts
+++ b/packages/opencode/src/auth/index.ts
@@ -1,6 +1,7 @@
import path from "path"
import { Global } from "../global"
import z from "zod"
+import { Filesystem } from "../util/filesystem"
export const OAUTH_DUMMY_KEY = "opencode-oauth-dummy-key"
@@ -42,8 +43,7 @@ export namespace Auth {
}
export async function all(): Promise<Record<string, Info>> {
- const file = Bun.file(filepath)
- const data = await file.json().catch(() => ({}) as Record<string, unknown>)
+ const data = await Filesystem.readJson<Record<string, unknown>>(filepath).catch(() => ({}))
return Object.entries(data).reduce(
(acc, [key, value]) => {
const parsed = Info.safeParse(value)
@@ -56,15 +56,13 @@ export namespace Auth {
}
export async function set(key: string, info: Info) {
- const file = Bun.file(filepath)
const data = await all()
- await Bun.write(file, JSON.stringify({ ...data, [key]: info }, null, 2), { mode: 0o600 })
+ await Filesystem.writeJson(filepath, { ...data, [key]: info }, 0o600)
}
export async function remove(key: string) {
- const file = Bun.file(filepath)
const data = await all()
delete data[key]
- await Bun.write(file, JSON.stringify(data, null, 2), { mode: 0o600 })
+ await Filesystem.writeJson(filepath, data, 0o600)
}
}