refactor: migrate cli/cmd/mcp.ts from Bun.file()/Bun.write() to Filesystem module
Replace Bun-specific file operations with Filesystem module: - Replace Bun.file().exists() with Filesystem.exists() - Replace Bun.file().text() with Filesystem.readText() - Replace Bun.write() with Filesystem.write()pull/14156/head
parent
3aaf29b693
commit
ad30e5b378
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue