unsavedIn
uses node:fs
The scratch files in a directory (a session's) holding work that isn't saved: any with something in it, since
saving one deletes it. Code, or a file kept as written that tcm edit wrote there (a page, a Dockerfile): any
but the session's own (its package.json, tsconfig.json and session.json) and declarations.
import fs from "node:fs"; import path from "node:path"; export function unsavedIn(dir: string): string[] { if (!fs.existsSync(dir)) return []; return fs .readdirSync(dir, { withFileTypes: true }) .filter( (e) => e.isFile() && !["package.json", "tsconfig.json", "session.json"].includes(e.name) && !e.name.endsWith(".d.ts") && !!fs.readFileSync(path.join(dir, e.name), "utf8").trim(), ) .map((e) => path.join(dir, e.name)); }