nose-pluto/bin/ls.tsx
2025-10-01 21:39:43 -07:00

22 lines
609 B
TypeScript

// Look around.
import { readdirSync } from "fs"
import { projectName, projectDir } from "@/project"
import { sessionGet } from "@/session"
export default function () {
const root = sessionGet("cwd") || projectDir()
let files: string[] = []
for (const file of readdirSync(root, { withFileTypes: true })) {
files.push(file.isDirectory() ? `${file.name}/` : file.name)
}
return <>
{root !== projectDir() && <a href="#cd ..;ls">..</a>}
{files.map(file =>
<a href={file.endsWith('/') ? `#cd ${file};ls` : `#cat ${file}`}>{file}</a>
)}
</>
}