20 lines
628 B
TypeScript
20 lines
628 B
TypeScript
// List all the games installed on the system.
|
|
|
|
import { readdirSync } from "fs"
|
|
import { join } from "path"
|
|
import { NOSE_BIN } from "@/config"
|
|
|
|
export default async function () {
|
|
let games = await Promise.all(readdirSync(NOSE_BIN, { withFileTypes: true }).map(async file => {
|
|
if (!file.isFile()) return
|
|
|
|
const code = await Bun.file(join(NOSE_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>)}
|
|
</>
|
|
} |