tsx support

This commit is contained in:
Chris Wanstrath 2025-09-21 21:28:29 -07:00
parent 5f494ede79
commit b7e99755f1
3 changed files with 18 additions and 7 deletions

View File

@ -71,6 +71,14 @@
color: var(--c64-dark-blue); color: var(--c64-dark-blue);
} }
a {
color: var(--cyan);
}
a:visited {
color: var(--purple);
}
html, html,
body { body {
font-family: var(--font-family); font-family: var(--font-family);

View File

@ -79,8 +79,7 @@ app.get("/apps", c => {
return c.html(<> return c.html(<>
<h1>apps</h1> <h1>apps</h1>
<ul>{apps().map(app => <li><a href={`http://${app}.${domain}${port}`}>{app}</a></li>)} <ul>{apps().map(app => <li><a href={`http://${app}.${domain}${port}`}>{app}</a></li>)}</ul>
</ul>
</>) </>)
}) })

View File

@ -1,9 +1,9 @@
//// ////
// runs commands and such. // runs commands and such.
import { join } from "path"
import type { CommandResult, CommandOutput } from "./shared/types" import type { CommandResult, CommandOutput } from "./shared/types"
import type { State } from "./state" import type { State } from "./state"
import { join } from "path"
import { NOSE_SYS_BIN, NOSE_BIN } from "./config" import { NOSE_SYS_BIN, NOSE_BIN } from "./config"
import { isFile } from "./utils" import { isFile } from "./utils"
import { ALS } from "./state" import { ALS } from "./state"
@ -46,6 +46,8 @@ function processExecOutput(output: string | any): ["ok" | "error", CommandOutput
} else if (typeof output === "object") { } else if (typeof output === "object") {
if (output.error) { if (output.error) {
return ["error", output.error] return ["error", output.error]
} else if (output.tag && output.props && output.children) {
return ["ok", { html: output.toString() }]
} else { } else {
return ["ok", output] return ["ok", output]
} }
@ -65,10 +67,12 @@ function getState(session: string, id: string): State {
} }
function commandPath(cmd: string): string | undefined { function commandPath(cmd: string): string | undefined {
const sysPath = join(NOSE_SYS_BIN, cmd + ".ts") return [
const usrPath = join(NOSE_BIN, cmd + ".ts") join(NOSE_SYS_BIN, cmd + ".ts"),
join(NOSE_SYS_BIN, cmd + ".tsx"),
return (isFile(sysPath) && sysPath) || (isFile(usrPath) && usrPath) || undefined join(NOSE_BIN, cmd + ".ts"),
join(NOSE_BIN, cmd + ".tsx")
].find((path: string) => isFile(path))
} }
function commandExists(cmd: string): boolean { function commandExists(cmd: string): boolean {