| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 1f86aa8 commit 50dfa9c
7 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,6 @@ | |||
| 1 | 1 | { | |
| 2 | 2 | "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=" | ||
| 5 | 5 | } | |
| 6 | 6 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,7 +4,7 @@ | |||
| 4 | 4 | "description": "AI-powered development tool", | |
| 5 | 5 | "private": true, | |
| 6 | 6 | "type": "module", | |
| 7 | - "packageManager": "bun@1.3.5", | ||
| 7 | + "packageManager": "bun@1.3.6", | ||
| 8 | 8 | "scripts": { | |
| 9 | 9 | "dev": "bun run --cwd packages/opencode --conditions=browser src/index.ts", | |
| 10 | 10 | "typecheck": "bun turbo typecheck", | |
@@ -21,7 +21,7 @@ | |||
| 21 | 21 | "packages/slack" | |
| 22 | 22 | ], | |
| 23 | 23 | "catalog": { | |
| 24 | - "@types/bun": "1.3.4", | ||
| 24 | + "@types/bun": "1.3.6", | ||
| 25 | 25 | "@octokit/rest": "22.0.0", | |
| 26 | 26 | "@hono/zod-validator": "0.4.2", | |
| 27 | 27 | "ulid": "3.0.1", | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,7 +6,6 @@ import { ConfigMarkdown } from "../config/markdown" | |||
| 6 | 6 | import { Log } from "../util/log" | |
| 7 | 7 | import { Global } from "@/global" | |
| 8 | 8 | import { Filesystem } from "@/util/filesystem" | |
| 9 | - import { exists } from "fs/promises" | ||
| 10 | 9 | import { Flag } from "@/flag/flag" | |
| 11 | 10 | ||
| 12 | 11 | export namespace Skill { | |
@@ -77,7 +76,7 @@ export namespace Skill { | |||
| 77 | 76 | ) | |
| 78 | 77 | // Also include global ~/.claude/skills/ | |
| 79 | 78 | const globalClaude = `${Global.Path.home}/.claude` | |
| 80 | - if (await exists(globalClaude)) { | ||
| 79 | + if (await Filesystem.isDir(globalClaude)) { | ||
| 81 | 80 | claudeDirs.push(globalClaude) | |
| 82 | 81 | } | |
| 83 | 82 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,6 +2,7 @@ import { Log } from "../util/log" | |||
| 2 | 2 | import path from "path" | |
| 3 | 3 | import fs from "fs/promises" | |
| 4 | 4 | import { Global } from "../global" | |
| 5 | + import { Filesystem } from "../util/filesystem" | ||
| 5 | 6 | import { lazy } from "../util/lazy" | |
| 6 | 7 | import { Lock } from "../util/lock" | |
| 7 | 8 | import { $ } from "bun" | |
@@ -23,7 +24,7 @@ export namespace Storage { | |||
| 23 | 24 | const MIGRATIONS: Migration[] = [ | |
| 24 | 25 | async (dir) => { | |
| 25 | 26 | const project = path.resolve(dir, "../project") | |
| 26 | - if (!fs.exists(project)) return | ||
| 27 | + if (!(await Filesystem.isDir(project))) return | ||
| 27 | 28 | for await (const projectDir of new Bun.Glob("*").scan({ | |
| 28 | 29 | cwd: project, | |
| 29 | 30 | onlyFiles: false, | |
@@ -43,7 +44,7 @@ export namespace Storage { | |||
| 43 | 44 | if (worktree) break | |
| 44 | 45 | } | |
| 45 | 46 | if (!worktree) continue | |
| 46 | - if (!(await fs.exists(worktree))) continue | ||
| 47 | + if (!(await Filesystem.isDir(worktree))) continue | ||
| 47 | 48 | const [id] = await $`git rev-list --max-parents=0 --all` | |
| 48 | 49 | .quiet() | |
| 49 | 50 | .nothrow() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,8 +1,18 @@ | |||
| 1 | 1 | import { realpathSync } from "fs" | |
| 2 | - import { exists } from "fs/promises" | ||
| 3 | 2 | import { dirname, join, relative } from "path" | |
| 4 | 3 | ||
| 5 | 4 | 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) | ||
| 6 | 16 | /** | |
| 7 | 17 | * On Windows, normalize a path to its canonical casing using the filesystem. | |
| 8 | 18 | * This is needed because Windows paths are case-insensitive but LSP servers | |
@@ -31,7 +41,7 @@ export namespace Filesystem { | |||
| 31 | 41 | const result = [] | |
| 32 | 42 | while (true) { | |
| 33 | 43 | const search = join(current, target) | |
| 34 | - if (await exists(search).catch(() => false)) result.push(search) | ||
| 44 | + if (await exists(search)) result.push(search) | ||
| 35 | 45 | if (stop === current) break | |
| 36 | 46 | const parent = dirname(current) | |
| 37 | 47 | if (parent === current) break | |
@@ -46,7 +56,7 @@ export namespace Filesystem { | |||
| 46 | 56 | while (true) { | |
| 47 | 57 | for (const target of targets) { | |
| 48 | 58 | const search = join(current, target) | |
| 49 | - if (await exists(search).catch(() => false)) yield search | ||
| 59 | + if (await exists(search)) yield search | ||
| 50 | 60 | } | |
| 51 | 61 | if (stop === current) break | |
| 52 | 62 | const parent = dirname(current) | |
| Original file line number | Diff line number | Diff 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 | + }) | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments