This commit is contained in:
Chris Wanstrath 2025-09-20 19:19:58 -07:00
parent 24ce536873
commit 8dc8cb65db
2 changed files with 11 additions and 2 deletions

View File

@ -1,3 +1,3 @@
export default function (...args: string[]): string { function (...args: string[]): string {
return args.join(" ") return args.join(" ")
} }

View File

@ -20,7 +20,7 @@ export async function runCommand(input: string): Promise<CommandResult> {
[status, output] = await exec(cmd, args) [status, output] = await exec(cmd, args)
} catch (err) { } catch (err) {
status = "error" status = "error"
output = err instanceof Error ? err.message : String(err) output = errorMessage(err)
} }
console.log("cmd", cmd) console.log("cmd", cmd)
@ -33,6 +33,15 @@ function commandExists(cmd: string): boolean {
return isFile(join(NOSE_BIN, cmd + ".ts")) return isFile(join(NOSE_BIN, cmd + ".ts"))
} }
function errorMessage(error: Error | any): string {
if (!(error instanceof Error))
return String(error)
let msg = `${error.name}: ${error.message}`
if (error.stack) msg += `\n${error.stack}`
return msg
}
async function exec(cmd: string, args: string[]): Promise<["ok" | "error", string]> { async function exec(cmd: string, args: string[]): Promise<["ok" | "error", string]> {
const path = join(NOSE_BIN, cmd + ".ts") const path = join(NOSE_BIN, cmd + ".ts")
const module = await import(path + "?t+" + Date.now()) const module = await import(path + "?t+" + Date.now())