isAsset
uses node:path
Whether a mirror keeps a file as a file of the codebase: anything but code (TypeScript), configuration and scripts included.
import { FILES_MARK } from "#codebase/tcmts/cli/mirror"; import fs from "node:fs"; import path from "node:path"; export const isAsset = (file: string, root = ""): boolean => { if (!/\.(m|c)?tsx?$/.test(file)) return true; // or anything in a directory marked as holding files (examples: scratch files, kept as written) for (let d = path.dirname(path.resolve(root, file)); root && d.startsWith(path.resolve(root)) && d !== path.dirname(d); d = path.dirname(d)) { if (fs.existsSync(path.join(d, FILES_MARK))) return true; } return false; }