mike-backend / backend /scripts /assert-no-src-js.mjs
bardd's picture
Deploy Mike backend-only Space
06671aa verified
Raw History Blame Contribute Delete
895 Bytes
import { readdirSync, statSync } from "node:fs";
import { join, relative } from "node:path";
const root = process.cwd();
const srcDir = join(root, "src");
const offenders = [];
function walk(dir) {
for (const entry of readdirSync(dir)) {
const full = join(dir, entry);
const stat = statSync(full);
if (stat.isDirectory()) {
walk(full);
continue;
}
if (entry.endsWith(".js") || entry.endsWith(".js.map")) {
offenders.push(relative(root, full));
}
}
}
walk(srcDir);
if (offenders.length > 0) {
console.error("");
console.error("ERROR: Generated JavaScript files were found inside backend/src.");
console.error("backend/src must contain TypeScript source only.");
console.error("");
console.error("Delete these files:");
for (const file of offenders) {
console.error(` - ${file}`);
}
console.error("");
process.exit(1);
}