mirror of
https://github.com/sst/opencode.git
synced 2025-08-04 05:28:16 +00:00
better detection of prettier formatter
This commit is contained in:
parent
0ee3b1ede2
commit
8404a97c3e
2 changed files with 8 additions and 17 deletions
|
@ -1,5 +1,7 @@
|
|||
import { App } from "../app/app"
|
||||
import { BunProc } from "../bun"
|
||||
import { Filesystem } from "../util/filesystem"
|
||||
import path from "path"
|
||||
|
||||
export interface Info {
|
||||
name: string
|
||||
|
@ -62,23 +64,12 @@ export const prettier: Info = {
|
|||
".gql",
|
||||
],
|
||||
async enabled() {
|
||||
// this is more complicated because we only want to use prettier if it's
|
||||
// being used with the current project
|
||||
try {
|
||||
const proc = Bun.spawn({
|
||||
cmd: [BunProc.which(), "run", "prettier", "--version"],
|
||||
cwd: App.info().path.cwd,
|
||||
env: {
|
||||
BUN_BE_BUN: "1",
|
||||
},
|
||||
stdout: "ignore",
|
||||
stderr: "ignore",
|
||||
})
|
||||
const exit = await proc.exited
|
||||
return exit === 0
|
||||
} catch {
|
||||
return false
|
||||
const app = App.info()
|
||||
const nms = await Filesystem.findUp("node_modules", app.path.cwd, app.path.root)
|
||||
for (const item of nms) {
|
||||
if (await Bun.file(path.join(item, ".bin", "prettier")).exists()) return true
|
||||
}
|
||||
return false
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -390,7 +390,7 @@ export namespace Session {
|
|||
}),
|
||||
).then((x) => x.flat())
|
||||
|
||||
if (true)
|
||||
if (input.mode === "plan")
|
||||
input.parts.push({
|
||||
type: "text",
|
||||
text: PROMPT_PLAN,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue