This commit is contained in:
Chris Wanstrath 2025-09-21 12:10:14 -07:00
parent c6ff2412d1
commit fa4f103ad4
5 changed files with 15 additions and 8 deletions

View File

@ -17,7 +17,7 @@
Commands can return one of two types:
- string
- { status: "ok" | "error", output: string }
- { error: string }
## Fonts

View File

@ -8,5 +8,5 @@ export default function (project: string) {
state.project = project
}
return state?.project ? `loaded ${project}` : { status: "error", output: `failed to load ${project}` }
return state?.project ? `loaded ${project}` : { error: `failed to load ${project}` }
}

View File

@ -5,13 +5,13 @@ import { appPath } from "@/webapp"
export default function () {
const state = Thread.getStore()
if (!state) return { status: "error", output: "no state" }
if (!state) return { error: "no state" }
const project = state.project
if (!project) return { status: "error", output: "no project loaded" }
if (!project) return { error: "no project loaded" }
const root = appPath(project)
if (!root) return { status: "error", output: "error loading project" }
if (!root) return { error: "error loading project" }
let files: string[] = []
@ -23,5 +23,5 @@ export default function () {
files = files.filter(file => file.endsWith(`${project}.ts`) || file.endsWith(`${project}.tsx`))
}
return `* project: ${project}\n` + files.join(" ")
return files.join(" ")
}

View File

@ -1,5 +1,8 @@
import { Thread } from "@/shell"
export default function () {
return Thread.getStore()?.project || "none"
const state = Thread.getStore()
if (!state) return { error: "no state" }
return state?.project || "none"
}

View File

@ -58,7 +58,11 @@ async function exec(cmd: string, args: string[]): Promise<["ok" | "error", strin
if (typeof output === "string") {
return ["ok", output]
} else if (typeof output === "object") {
return [output.status || "ok", output.output]
if (output.error) {
return ["error", output.error]
} else {
return ["ok", JSON.stringify(output)]
}
} else {
return ["ok", String(output)]
}