Skip to content

Commit 5fe237a

Browse files
authored
refactor: migrate src/skill/discovery.ts from Bun.file()/Bun.write() to Filesystem module (#14133)
1 parent ae39853 commit 5fe237a

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

packages/opencode/src/skill/discovery.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import path from "path"
22
import { mkdir } from "fs/promises"
33
import { Log } from "../util/log"
44
import { Global } from "../global"
5+
import { Filesystem } from "../util/filesystem"
56

67
export namespace Discovery {
78
const log = Log.create({ service: "skill-discovery" })
@@ -19,14 +20,14 @@ export namespace Discovery {
1920
}
2021

2122
async function get(url: string, dest: string): Promise<boolean> {
22-
if (await Bun.file(dest).exists()) return true
23+
if (await Filesystem.exists(dest)) return true
2324
return fetch(url)
2425
.then(async (response) => {
2526
if (!response.ok) {
2627
log.error("failed to download", { url, status: response.status })
2728
return false
2829
}
29-
await Bun.write(dest, await response.text())
30+
if (response.body) await Filesystem.writeStream(dest, response.body)
3031
return true
3132
})
3233
.catch((err) => {
@@ -88,7 +89,7 @@ export namespace Discovery {
8889
)
8990

9091
const md = path.join(root, "SKILL.md")
91-
if (await Bun.file(md).exists()) result.push(root)
92+
if (await Filesystem.exists(md)) result.push(root)
9293
}),
9394
)
9495

0 commit comments

Comments
 (0)