games command
This commit is contained in:
parent
40b5bb3df3
commit
877f888c96
20
bin/games.tsx
Normal file
20
bin/games.tsx
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// 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>)}
|
||||
</>
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user