refactor: migrate file/ripgrep.ts from Bun.file()/Bun.write() to Filesystem module (#14159)

This commit is contained in:
Dax
2026-02-18 12:10:42 -05:00
committed by GitHub
parent 91a3ee642d
commit 3d189b42a3
3 changed files with 46 additions and 53 deletions

View File

@@ -13,6 +13,7 @@ import { Installation } from "../../installation"
import path from "path"
import { Global } from "../../global"
import { modify, applyEdits } from "jsonc-parser"
import { Filesystem } from "../../util/filesystem"
import { Bus } from "../../bus"
function getAuthStatusIcon(status: MCP.AuthStatus): string {
@@ -388,7 +389,7 @@ async function resolveConfigPath(baseDir: string, global = false) {
}
for (const candidate of candidates) {
if (await Bun.file(candidate).exists()) {
if (await Filesystem.exists(candidate)) {
return candidate
}
}
@@ -398,11 +399,9 @@ async function resolveConfigPath(baseDir: string, global = false) {
}
async function addMcpToConfig(name: string, mcpConfig: Config.Mcp, configPath: string) {
const file = Bun.file(configPath)
let text = "{}"
if (await file.exists()) {
text = await file.text()
if (await Filesystem.exists(configPath)) {
text = await Filesystem.readText(configPath)
}
// Use jsonc-parser to modify while preserving comments
@@ -411,7 +410,7 @@ async function addMcpToConfig(name: string, mcpConfig: Config.Mcp, configPath: s
})
const result = applyEdits(text, edits)
await Bun.write(configPath, result)
await Filesystem.write(configPath, result)
return configPath
}