27 lines
749 B
TypeScript
27 lines
749 B
TypeScript
import { readdirSync } from "fs"
|
|
import { NOSE_WWW } from "app/src/config"
|
|
import { getState } from "app/src/state"
|
|
import { appPath } from "app/src/webapp"
|
|
|
|
export default function () {
|
|
const state = getState()
|
|
if (!state) return { error: "no state" }
|
|
|
|
const project = state.project
|
|
if (!project) return { error: "no project loaded" }
|
|
|
|
const root = appPath(project)
|
|
if (!root) return { error: "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 files.join(" ")
|
|
} |