Skip to content

Commit 50dfa9c

Browse files
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 (anomalyco#8499)
Co-authored-by: Github Action <action@github.com>
1 parent 1f86aa8 commit 50dfa9c

File tree

7 files changed

+63
-14
lines changed

7 files changed

+63
-14
lines changed

bun.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nix/hashes.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"nodeModules": {
3-
"x86_64-linux": "sha256-1l4twtOi/7YYy1KFJME1XazAgTETAfbxB3EOv2qQeVs=",
4-
"aarch64-darwin": "sha256-jdZI3BA/v35er4xgWkI2rHo54D1TDNVhMX83b5BcIvk="
3+
"x86_64-linux": "sha256-GKdu7nan/9ioBtgL3cUeuVLNKUDio10LeQrn7BPgbng=",
4+
"aarch64-darwin": "sha256-STLB1J65VjauvPM+BqCyTQQkHPoVmUhDvVEdH3WTJP4="
55
}
66
}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "AI-powered development tool",
55
"private": true,
66
"type": "module",
7-
"packageManager": "bun@1.3.5",
7+
"packageManager": "bun@1.3.6",
88
"scripts": {
99
"dev": "bun run --cwd packages/opencode --conditions=browser src/index.ts",
1010
"typecheck": "bun turbo typecheck",
@@ -21,7 +21,7 @@
2121
"packages/slack"
2222
],
2323
"catalog": {
24-
"@types/bun": "1.3.4",
24+
"@types/bun": "1.3.6",
2525
"@octokit/rest": "22.0.0",
2626
"@hono/zod-validator": "0.4.2",
2727
"ulid": "3.0.1",

packages/opencode/src/skill/skill.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { ConfigMarkdown } from "../config/markdown"
66
import { Log } from "../util/log"
77
import { Global } from "@/global"
88
import { Filesystem } from "@/util/filesystem"
9-
import { exists } from "fs/promises"
109
import { Flag } from "@/flag/flag"
1110

1211
export namespace Skill {
@@ -77,7 +76,7 @@ export namespace Skill {
7776
)
7877
// Also include global ~/.claude/skills/
7978
const globalClaude = `${Global.Path.home}/.claude`
80-
if (await exists(globalClaude)) {
79+
if (await Filesystem.isDir(globalClaude)) {
8180
claudeDirs.push(globalClaude)
8281
}
8382

packages/opencode/src/storage/storage.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Log } from "../util/log"
22
import path from "path"
33
import fs from "fs/promises"
44
import { Global } from "../global"
5+
import { Filesystem } from "../util/filesystem"
56
import { lazy } from "../util/lazy"
67
import { Lock } from "../util/lock"
78
import { $ } from "bun"
@@ -23,7 +24,7 @@ export namespace Storage {
2324
const MIGRATIONS: Migration[] = [
2425
async (dir) => {
2526
const project = path.resolve(dir, "../project")
26-
if (!fs.exists(project)) return
27+
if (!(await Filesystem.isDir(project))) return
2728
for await (const projectDir of new Bun.Glob("*").scan({
2829
cwd: project,
2930
onlyFiles: false,
@@ -43,7 +44,7 @@ export namespace Storage {
4344
if (worktree) break
4445
}
4546
if (!worktree) continue
46-
if (!(await fs.exists(worktree))) continue
47+
if (!(await Filesystem.isDir(worktree))) continue
4748
const [id] = await $`git rev-list --max-parents=0 --all`
4849
.quiet()
4950
.nothrow()

packages/opencode/src/util/filesystem.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
import { realpathSync } from "fs"
2-
import { exists } from "fs/promises"
32
import { dirname, join, relative } from "path"
43

54
export namespace Filesystem {
5+
export const exists = (p: string) =>
6+
Bun.file(p)
7+
.stat()
8+
.then(() => true)
9+
.catch(() => false)
10+
11+
export const isDir = (p: string) =>
12+
Bun.file(p)
13+
.stat()
14+
.then((s) => s.isDirectory())
15+
.catch(() => false)
616
/**
717
* On Windows, normalize a path to its canonical casing using the filesystem.
818
* This is needed because Windows paths are case-insensitive but LSP servers
@@ -31,7 +41,7 @@ export namespace Filesystem {
3141
const result = []
3242
while (true) {
3343
const search = join(current, target)
34-
if (await exists(search).catch(() => false)) result.push(search)
44+
if (await exists(search)) result.push(search)
3545
if (stop === current) break
3646
const parent = dirname(current)
3747
if (parent === current) break
@@ -46,7 +56,7 @@ export namespace Filesystem {
4656
while (true) {
4757
for (const target of targets) {
4858
const search = join(current, target)
49-
if (await exists(search).catch(() => false)) yield search
59+
if (await exists(search)) yield search
5060
}
5161
if (stop === current) break
5262
const parent = dirname(current)
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { describe, expect, test } from "bun:test"
2+
import os from "node:os"
3+
import path from "node:path"
4+
import { mkdtemp, mkdir, rm } from "node:fs/promises"
5+
import { Filesystem } from "../../src/util/filesystem"
6+
7+
describe("util.filesystem", () => {
8+
test("exists() is true for files and directories", async () => {
9+
const tmp = await mkdtemp(path.join(os.tmpdir(), "opencode-filesystem-"))
10+
const dir = path.join(tmp, "dir")
11+
const file = path.join(tmp, "file.txt")
12+
const missing = path.join(tmp, "missing")
13+
14+
await mkdir(dir, { recursive: true })
15+
await Bun.write(file, "hello")
16+
17+
const cases = await Promise.all([Filesystem.exists(dir), Filesystem.exists(file), Filesystem.exists(missing)])
18+
19+
expect(cases).toEqual([true, true, false])
20+
21+
await rm(tmp, { recursive: true, force: true })
22+
})
23+
24+
test("isDir() is true only for directories", async () => {
25+
const tmp = await mkdtemp(path.join(os.tmpdir(), "opencode-filesystem-"))
26+
const dir = path.join(tmp, "dir")
27+
const file = path.join(tmp, "file.txt")
28+
const missing = path.join(tmp, "missing")
29+
30+
await mkdir(dir, { recursive: true })
31+
await Bun.write(file, "hello")
32+
33+
const cases = await Promise.all([Filesystem.isDir(dir), Filesystem.isDir(file), Filesystem.isDir(missing)])
34+
35+
expect(cases).toEqual([true, false, false])
36+
37+
await rm(tmp, { recursive: true, force: true })
38+
})
39+
})

0 commit comments

Comments
 (0)