shippedApp
uses node:fs
An app the running tcm's package ships (apps in its manifest): its directory beside the package's code
(<package>/apps/<name>, holding its codebase), or undefined if it ships none of that name (a tcm run from a
codebase rather than a package).
import fs from "node:fs"; import path from "node:path"; export function shippedApp(name: string): string | undefined { const bin = process.argv[1]; const beside = bin && fs.existsSync(bin) ? path.join(path.dirname(path.dirname(fs.realpathSync(bin))), "apps", name) : undefined; // (or, for a tcm run from its codebase, as suites run it, where they packed its apps: `TCM_APPS`) for (const dir of [beside, process.env.TCM_APPS && path.join(process.env.TCM_APPS, name)]) if (dir && fs.existsSync(path.join(dir, "codebase.sqlite"))) return dir; return undefined; }