refactor: migrate config/markdown.ts from Bun.file() to Filesystem module (#14151)

This commit is contained in:
Dax
2026-02-18 12:35:32 -05:00
committed by GitHub
parent ef155f3766
commit 8f4a72c57a
2 changed files with 6 additions and 6 deletions

View File

@@ -7,6 +7,7 @@ import { $ } from "bun"
import fs from "fs/promises" import fs from "fs/promises"
import path from "path" import path from "path"
import os from "os" import os from "os"
import { Filesystem } from "../../util/filesystem"
interface UninstallArgs { interface UninstallArgs {
keepConfig: boolean keepConfig: boolean
@@ -267,9 +268,7 @@ async function getShellConfigFile(): Promise<string | null> {
.catch(() => false) .catch(() => false)
if (!exists) continue if (!exists) continue
const content = await Bun.file(file) const content = await Filesystem.readText(file).catch(() => "")
.text()
.catch(() => "")
if (content.includes("# opencode") || content.includes(".opencode/bin")) { if (content.includes("# opencode") || content.includes(".opencode/bin")) {
return file return file
} }
@@ -279,7 +278,7 @@ async function getShellConfigFile(): Promise<string | null> {
} }
async function cleanShellConfig(file: string) { async function cleanShellConfig(file: string) {
const content = await Bun.file(file).text() const content = await Filesystem.readText(file)
const lines = content.split("\n") const lines = content.split("\n")
const filtered: string[] = [] const filtered: string[] = []
@@ -315,7 +314,7 @@ async function cleanShellConfig(file: string) {
} }
const output = filtered.join("\n") + "\n" const output = filtered.join("\n") + "\n"
await Bun.write(file, output) await Filesystem.write(file, output)
} }
async function getDirectorySize(dir: string): Promise<number> { async function getDirectorySize(dir: string): Promise<number> {

View File

@@ -1,6 +1,7 @@
import { NamedError } from "@opencode-ai/util/error" import { NamedError } from "@opencode-ai/util/error"
import matter from "gray-matter" import matter from "gray-matter"
import { z } from "zod" import { z } from "zod"
import { Filesystem } from "../util/filesystem"
export namespace ConfigMarkdown { export namespace ConfigMarkdown {
export const FILE_REGEX = /(?<![\w`])@(\.?[^\s`,.]*(?:\.[^\s`,.]+)*)/g export const FILE_REGEX = /(?<![\w`])@(\.?[^\s`,.]*(?:\.[^\s`,.]+)*)/g
@@ -68,7 +69,7 @@ export namespace ConfigMarkdown {
} }
export async function parse(filePath: string) { export async function parse(filePath: string) {
const template = await Bun.file(filePath).text() const template = await Filesystem.readText(filePath)
try { try {
const md = matter(template) const md = matter(template)