nose-pluto/app/src/project.ts
2025-09-28 15:53:45 -07:00

27 lines
626 B
TypeScript

////
// Helpers for working with projects in the CLI.
import { readdirSync, type Dirent } from "fs"
import { getState } from "./session"
import { appDir } from "./webapp"
export function projectName(): string {
const state = getState()
if (!state) throw "no state"
const project = state.project
if (!project) throw "no project loaded"
return project
}
export function projectDir(): string {
const root = appDir(projectName())
if (!root) throw "error loading project"
return root
}
export function projectFiles(): Dirent[] {
return readdirSync(projectDir(), { recursive: true, withFileTypes: true })
}