Skip to content

Commit 36bc07a

Browse files
authored
refactor: migrate src/tool/write.ts from Bun.file() to Filesystem module (anomalyco#14119)
1 parent 270b807 commit 36bc07a

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

‎packages/opencode/src/tool/write.ts‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ export const WriteTool = Tool.define("write", {
2626
const filepath = path.isAbsolute(params.filePath) ? params.filePath : path.join(Instance.directory, params.filePath)
2727
await assertExternalDirectory(ctx, filepath)
2828

29-
const file = Bun.file(filepath)
30-
const exists = await file.exists()
31-
const contentOld = exists ? await file.text() : ""
29+
const exists = await Filesystem.exists(filepath)
30+
const contentOld = exists ? await Filesystem.readText(filepath) : ""
3231
if (exists) await FileTime.assert(ctx.sessionID, filepath)
3332

3433
const diff = trimDiff(createTwoFilesPatch(filepath, filepath, contentOld, params.content))
@@ -42,7 +41,7 @@ export const WriteTool = Tool.define("write", {
4241
},
4342
})
4443

45-
await Bun.write(filepath, params.content)
44+
await Filesystem.write(filepath, params.content)
4645
await Bus.publish(File.Event.Edited, {
4746
file: filepath,
4847
})

0 commit comments

Comments
 (0)