diff options
| author | Aiden Cline <[email protected]> | 2026-01-14 09:53:12 -0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-01-14 11:53:12 -0600 |
| commit | 50dfa9caf3dd01daf50bc20aca1c91a21bfe436c (patch) | |
| tree | 5cae2bfafa4f45970188fa9bbc57d347b0916e30 /packages | |
| parent | 1f86aa8bb97289f052c4c69579b24f2ff20b3d5a (diff) | |
| download | opencode-50dfa9caf3dd01daf50bc20aca1c91a21bfe436c.tar.gz opencode-50dfa9caf3dd01daf50bc20aca1c91a21bfe436c.zip | |
chore: upgrade bun from 1.3.5 -> 1.3.6, also update types/bun from 1.3.4 -> 1.3.6 and fix type errs (#8499)
Co-authored-by: Github Action <[email protected]>
Diffstat (limited to 'packages')
| -rw-r--r-- | packages/opencode/src/skill/skill.ts | 3 | ||||
| -rw-r--r-- | packages/opencode/src/storage/storage.ts | 5 | ||||
| -rw-r--r-- | packages/opencode/src/util/filesystem.ts | 16 | ||||
| -rw-r--r-- | packages/opencode/test/util/filesystem.test.ts | 39 |
4 files changed, 56 insertions, 7 deletions
diff --git a/packages/opencode/src/skill/skill.ts b/packages/opencode/src/skill/skill.ts index cbc042d1e..1cc3afee9 100644 --- a/packages/opencode/src/skill/skill.ts +++ b/packages/opencode/src/skill/skill.ts @@ -6,7 +6,6 @@ import { ConfigMarkdown } from "../config/markdown" import { Log } from "../util/log" import { Global } from "@/global" import { Filesystem } from "@/util/filesystem" -import { exists } from "fs/promises" import { Flag } from "@/flag/flag" export namespace Skill { @@ -77,7 +76,7 @@ export namespace Skill { ) // Also include global ~/.claude/skills/ const globalClaude = `${Global.Path.home}/.claude` - if (await exists(globalClaude)) { + if (await Filesystem.isDir(globalClaude)) { claudeDirs.push(globalClaude) } diff --git a/packages/opencode/src/storage/storage.ts b/packages/opencode/src/storage/storage.ts index 8b4042ea1..18f2d67e7 100644 --- a/packages/opencode/src/storage/storage.ts +++ b/packages/opencode/src/storage/storage.ts @@ -2,6 +2,7 @@ import { Log } from "../util/log" import path from "path" import fs from "fs/promises" import { Global } from "../global" +import { Filesystem } from "../util/filesystem" import { lazy } from "../util/lazy" import { Lock } from "../util/lock" import { $ } from "bun" @@ -23,7 +24,7 @@ export namespace Storage { const MIGRATIONS: Migration[] = [ async (dir) => { const project = path.resolve(dir, "../project") - if (!fs.exists(project)) return + if (!(await Filesystem.isDir(project))) return for await (const projectDir of new Bun.Glob("*").scan({ cwd: project, onlyFiles: false, @@ -43,7 +44,7 @@ export namespace Storage { if (worktree) break } if (!worktree) continue - if (!(await fs.exists(worktree))) continue + if (!(await Filesystem.isDir(worktree))) continue const [id] = await $`git rev-list --max-parents=0 --all` .quiet() .nothrow() diff --git a/packages/opencode/src/util/filesystem.ts b/packages/opencode/src/util/filesystem.ts index 472bff83d..7aff6bd1d 100644 --- a/packages/opencode/src/util/filesystem.ts +++ b/packages/opencode/src/util/filesystem.ts @@ -1,8 +1,18 @@ import { realpathSync } from "fs" -import { exists } from "fs/promises" import { dirname, join, relative } from "path" export namespace Filesystem { + export const exists = (p: string) => + Bun.file(p) + .stat() + .then(() => true) + .catch(() => false) + + export const isDir = (p: string) => + Bun.file(p) + .stat() + .then((s) => s.isDirectory()) + .catch(() => false) /** * On Windows, normalize a path to its canonical casing using the filesystem. * This is needed because Windows paths are case-insensitive but LSP servers @@ -31,7 +41,7 @@ export namespace Filesystem { const result = [] while (true) { const search = join(current, target) - if (await exists(search).catch(() => false)) result.push(search) + if (await exists(search)) result.push(search) if (stop === current) break const parent = dirname(current) if (parent === current) break @@ -46,7 +56,7 @@ export namespace Filesystem { while (true) { for (const target of targets) { const search = join(current, target) - if (await exists(search).catch(() => false)) yield search + if (await exists(search)) yield search } if (stop === current) break const parent = dirname(current) diff --git a/packages/opencode/test/util/filesystem.test.ts b/packages/opencode/test/util/filesystem.test.ts new file mode 100644 index 000000000..0e5f0ba38 --- /dev/null +++ b/packages/opencode/test/util/filesystem.test.ts @@ -0,0 +1,39 @@ +import { describe, expect, test } from "bun:test" +import os from "node:os" +import path from "node:path" +import { mkdtemp, mkdir, rm } from "node:fs/promises" +import { Filesystem } from "../../src/util/filesystem" + +describe("util.filesystem", () => { + test("exists() is true for files and directories", async () => { + const tmp = await mkdtemp(path.join(os.tmpdir(), "opencode-filesystem-")) + const dir = path.join(tmp, "dir") + const file = path.join(tmp, "file.txt") + const missing = path.join(tmp, "missing") + + await mkdir(dir, { recursive: true }) + await Bun.write(file, "hello") + + const cases = await Promise.all([Filesystem.exists(dir), Filesystem.exists(file), Filesystem.exists(missing)]) + + expect(cases).toEqual([true, true, false]) + + await rm(tmp, { recursive: true, force: true }) + }) + + test("isDir() is true only for directories", async () => { + const tmp = await mkdtemp(path.join(os.tmpdir(), "opencode-filesystem-")) + const dir = path.join(tmp, "dir") + const file = path.join(tmp, "file.txt") + const missing = path.join(tmp, "missing") + + await mkdir(dir, { recursive: true }) + await Bun.write(file, "hello") + + const cases = await Promise.all([Filesystem.isDir(dir), Filesystem.isDir(file), Filesystem.isDir(missing)]) + + expect(cases).toEqual([true, false, false]) + + await rm(tmp, { recursive: true, force: true }) + }) +}) |
