nose-pluto/nose/bin/ls.ts
Chris Wanstrath c6ff2412d1 new output
2025-09-21 11:42:09 -07:00

27 lines
818 B
TypeScript

import { readdirSync } from "fs"
import { NOSE_WWW } from "@/config"
import { Thread } from "@/shell"
import { appPath } from "@/webapp"
export default function () {
const state = Thread.getStore()
if (!state) return { status: "error", output: "no state" }
const project = state.project
if (!project) return { status: "error", output: "no project loaded" }
const root = appPath(project)
if (!root) return { status: "error", output: "error loading project" }
let files: string[] = []
for (const file of readdirSync(root, { withFileTypes: true })) {
files.push(file.name)
}
if (root === NOSE_WWW) {
files = files.filter(file => file.endsWith(`${project}.ts`) || file.endsWith(`${project}.tsx`))
}
return `* project: ${project}\n` + files.join(" ")
}