new output
This commit is contained in:
parent
d52341049f
commit
c6ff2412d1
|
|
@ -12,6 +12,13 @@
|
||||||
mkdir -p ~/nose/{bin,www}
|
mkdir -p ~/nose/{bin,www}
|
||||||
bun dev
|
bun dev
|
||||||
|
|
||||||
|
## Commands
|
||||||
|
|
||||||
|
Commands can return one of two types:
|
||||||
|
|
||||||
|
- string
|
||||||
|
- { status: "ok" | "error", output: string }
|
||||||
|
|
||||||
## Fonts
|
## Fonts
|
||||||
|
|
||||||
Use this to examine what's inside the C64 .woff2 font file in public/vendor:
|
Use this to examine what's inside the C64 .woff2 font file in public/vendor:
|
||||||
|
|
|
||||||
|
|
@ -8,5 +8,5 @@ export default function (project: string) {
|
||||||
state.project = project
|
state.project = project
|
||||||
}
|
}
|
||||||
|
|
||||||
return state?.project ? `loaded ${project}` : `failed to load ${project}`
|
return state?.project ? `loaded ${project}` : { status: "error", output: `failed to load ${project}` }
|
||||||
}
|
}
|
||||||
|
|
@ -1,17 +1,17 @@
|
||||||
import { readdirSync } from "fs"
|
import { readdirSync } from "fs"
|
||||||
import { NOSE_DIR, NOSE_WWW } from "@/config"
|
import { NOSE_WWW } from "@/config"
|
||||||
import { Thread } from "@/shell"
|
import { Thread } from "@/shell"
|
||||||
import { appPath } from "@/webapp"
|
import { appPath } from "@/webapp"
|
||||||
|
|
||||||
export default function () {
|
export default function () {
|
||||||
const state = Thread.getStore()
|
const state = Thread.getStore()
|
||||||
if (!state) return "error: no state"
|
if (!state) return { status: "error", output: "no state" }
|
||||||
|
|
||||||
const project = state.project
|
const project = state.project
|
||||||
if (!project) return "no project loaded"
|
if (!project) return { status: "error", output: "no project loaded" }
|
||||||
|
|
||||||
const root = appPath(project)
|
const root = appPath(project)
|
||||||
if (!root) return "error loading project"
|
if (!root) return { status: "error", output: "error loading project" }
|
||||||
|
|
||||||
let files: string[] = []
|
let files: string[] = []
|
||||||
|
|
||||||
|
|
|
||||||
10
src/shell.ts
10
src/shell.ts
|
|
@ -53,7 +53,15 @@ async function exec(cmd: string, args: string[]): Promise<["ok" | "error", strin
|
||||||
return ["error", `${cmd} has no default export`]
|
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 {
|
function commandPath(cmd: string): string | undefined {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user