new output

This commit is contained in:
Chris Wanstrath 2025-09-21 11:42:09 -07:00
parent d52341049f
commit c6ff2412d1
4 changed files with 21 additions and 6 deletions

View File

@ -12,6 +12,13 @@
mkdir -p ~/nose/{bin,www}
bun dev
## Commands
Commands can return one of two types:
- string
- { status: "ok" | "error", output: string }
## Fonts
Use this to examine what's inside the C64 .woff2 font file in public/vendor:

View File

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

View File

@ -1,17 +1,17 @@
import { readdirSync } from "fs"
import { NOSE_DIR, NOSE_WWW } from "@/config"
import { NOSE_WWW } from "@/config"
import { Thread } from "@/shell"
import { appPath } from "@/webapp"
export default function () {
const state = Thread.getStore()
if (!state) return "error: no state"
if (!state) return { status: "error", output: "no state" }
const project = state.project
if (!project) return "no project loaded"
if (!project) return { status: "error", output: "no project loaded" }
const root = appPath(project)
if (!root) return "error loading project"
if (!root) return { status: "error", output: "error loading project" }
let files: string[] = []

View File

@ -53,7 +53,15 @@ async function exec(cmd: string, args: string[]): Promise<["ok" | "error", strin
return ["error", `${cmd} has no default export`]
}
return ["ok", await module.default(...args)]
const output = await module.default(...args)
if (typeof output === "string") {
return ["ok", output]
} else if (typeof output === "object") {
return [output.status || "ok", output.output]
} else {
return ["ok", String(output)]
}
}
function commandPath(cmd: string): string | undefined {