nose-pluto/bin/games.tsx
2025-09-29 22:08:39 -07:00

20 lines
640 B
TypeScript

// List all the games installed on the system.
import { readdirSync } from "fs"
import { join } from "path"
import { NOSE_SYS_BIN } from "@/config"
export default async function () {
let games = await Promise.all(readdirSync(NOSE_SYS_BIN, { withFileTypes: true }).map(async file => {
if (!file.isFile()) return
const code = await Bun.file(join(NOSE_SYS_BIN, file.name)).text()
if (/^export const game\s*=\s*true\s*;?\s*$/m.test(code))
return file.name.replace(".tsx", "").replace(".ts", "")
})).then(games => games.filter(file => file))
return <>
{games.map(game => <a href={`#${game}`}>{game}</a>)}
</>
}