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