refactor: migrate src/cli/cmd/agent.ts from Bun.file()/Bun.write() to Filesystem module (#14142)
This commit is contained in:
@@ -6,6 +6,7 @@ import { Agent } from "../../agent/agent"
|
|||||||
import { Provider } from "../../provider/provider"
|
import { Provider } from "../../provider/provider"
|
||||||
import path from "path"
|
import path from "path"
|
||||||
import fs from "fs/promises"
|
import fs from "fs/promises"
|
||||||
|
import { Filesystem } from "../../util/filesystem"
|
||||||
import matter from "gray-matter"
|
import matter from "gray-matter"
|
||||||
import { Instance } from "../../project/instance"
|
import { Instance } from "../../project/instance"
|
||||||
import { EOL } from "os"
|
import { EOL } from "os"
|
||||||
@@ -202,8 +203,7 @@ const AgentCreateCommand = cmd({
|
|||||||
|
|
||||||
await fs.mkdir(targetPath, { recursive: true })
|
await fs.mkdir(targetPath, { recursive: true })
|
||||||
|
|
||||||
const file = Bun.file(filePath)
|
if (await Filesystem.exists(filePath)) {
|
||||||
if (await file.exists()) {
|
|
||||||
if (isFullyNonInteractive) {
|
if (isFullyNonInteractive) {
|
||||||
console.error(`Error: Agent file already exists: ${filePath}`)
|
console.error(`Error: Agent file already exists: ${filePath}`)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
@@ -212,7 +212,7 @@ const AgentCreateCommand = cmd({
|
|||||||
throw new UI.CancelledError()
|
throw new UI.CancelledError()
|
||||||
}
|
}
|
||||||
|
|
||||||
await Bun.write(filePath, content)
|
await Filesystem.write(filePath, content)
|
||||||
|
|
||||||
if (isFullyNonInteractive) {
|
if (isFullyNonInteractive) {
|
||||||
console.log(filePath)
|
console.log(filePath)
|
||||||
|
|||||||
Reference in New Issue
Block a user