refactor: migrate cli/cmd/run.ts from Bun.file() to Filesystem/stat modules (#14155)
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import path from "path"
|
import path from "path"
|
||||||
import { exec } from "child_process"
|
import { exec } from "child_process"
|
||||||
|
import { Filesystem } from "../../util/filesystem"
|
||||||
import * as prompts from "@clack/prompts"
|
import * as prompts from "@clack/prompts"
|
||||||
import { map, pipe, sortBy, values } from "remeda"
|
import { map, pipe, sortBy, values } from "remeda"
|
||||||
import { Octokit } from "@octokit/rest"
|
import { Octokit } from "@octokit/rest"
|
||||||
@@ -360,7 +361,7 @@ export const GithubInstallCommand = cmd({
|
|||||||
? ""
|
? ""
|
||||||
: `\n env:${providers[provider].env.map((e) => `\n ${e}: \${{ secrets.${e} }}`).join("")}`
|
: `\n env:${providers[provider].env.map((e) => `\n ${e}: \${{ secrets.${e} }}`).join("")}`
|
||||||
|
|
||||||
await Bun.write(
|
await Filesystem.write(
|
||||||
path.join(app.root, WORKFLOW_FILE),
|
path.join(app.root, WORKFLOW_FILE),
|
||||||
`name: opencode
|
`name: opencode
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { cmd } from "./cmd"
|
|||||||
import { Flag } from "../../flag/flag"
|
import { Flag } from "../../flag/flag"
|
||||||
import { bootstrap } from "../bootstrap"
|
import { bootstrap } from "../bootstrap"
|
||||||
import { EOL } from "os"
|
import { EOL } from "os"
|
||||||
|
import { Filesystem } from "../../util/filesystem"
|
||||||
import { createOpencodeClient, type Message, type OpencodeClient, type ToolPart } from "@opencode-ai/sdk/v2"
|
import { createOpencodeClient, type Message, type OpencodeClient, type ToolPart } from "@opencode-ai/sdk/v2"
|
||||||
import { Server } from "../../server/server"
|
import { Server } from "../../server/server"
|
||||||
import { Provider } from "../../provider/provider"
|
import { Provider } from "../../provider/provider"
|
||||||
@@ -315,19 +316,12 @@ export const RunCommand = cmd({
|
|||||||
|
|
||||||
for (const filePath of list) {
|
for (const filePath of list) {
|
||||||
const resolvedPath = path.resolve(process.cwd(), filePath)
|
const resolvedPath = path.resolve(process.cwd(), filePath)
|
||||||
const file = Bun.file(resolvedPath)
|
if (!(await Filesystem.exists(resolvedPath))) {
|
||||||
const stats = await file.stat().catch(() => {})
|
|
||||||
if (!stats) {
|
|
||||||
UI.error(`File not found: ${filePath}`)
|
|
||||||
process.exit(1)
|
|
||||||
}
|
|
||||||
if (!(await file.exists())) {
|
|
||||||
UI.error(`File not found: ${filePath}`)
|
UI.error(`File not found: ${filePath}`)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
const stat = await file.stat()
|
const mime = (await Filesystem.isDir(resolvedPath)) ? "application/x-directory" : "text/plain"
|
||||||
const mime = stat.isDirectory() ? "application/x-directory" : "text/plain"
|
|
||||||
|
|
||||||
files.push({
|
files.push({
|
||||||
type: "file",
|
type: "file",
|
||||||
|
|||||||
Reference in New Issue
Block a user