diff --git a/README.md b/README.md index 8d9d2e2..e140f02 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Commands can return one of two types: - string -- { status: "ok" | "error", output: string } +- { error: string } ## Fonts diff --git a/nose/bin/load.ts b/nose/bin/load.ts index f49c9ff..41ecad7 100644 --- a/nose/bin/load.ts +++ b/nose/bin/load.ts @@ -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}` } } \ No newline at end of file diff --git a/nose/bin/ls.ts b/nose/bin/ls.ts index dc599a9..e017c42 100644 --- a/nose/bin/ls.ts +++ b/nose/bin/ls.ts @@ -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(" ") } \ No newline at end of file diff --git a/nose/bin/project.ts b/nose/bin/project.ts index 89f0487..4997fb1 100644 --- a/nose/bin/project.ts +++ b/nose/bin/project.ts @@ -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" } \ No newline at end of file diff --git a/src/shell.ts b/src/shell.ts index afc4843..ab78bb5 100644 --- a/src/shell.ts +++ b/src/shell.ts @@ -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)] }