53 lines
1.1 KiB
JavaScript
53 lines
1.1 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
import { readdirSync, rmSync } from "node:fs";
|
|
import { join, relative } from "node:path";
|
|
|
|
const root = process.cwd();
|
|
const skippedDirectories = new Set([
|
|
".git",
|
|
".next",
|
|
".pnpm-store",
|
|
".turbo",
|
|
".venv",
|
|
"node_modules",
|
|
"playwright-report",
|
|
"test-results",
|
|
]);
|
|
|
|
const shouldRemove = (name) =>
|
|
name === ".DS_Store" || name === "tsconfig.tsbuildinfo" || name.endsWith(".swp");
|
|
|
|
const removed = [];
|
|
|
|
function walk(directory) {
|
|
for (const entry of readdirSync(directory, { withFileTypes: true })) {
|
|
const path = join(directory, entry.name);
|
|
if (entry.isDirectory()) {
|
|
if (skippedDirectories.has(entry.name)) {
|
|
continue;
|
|
}
|
|
walk(path);
|
|
continue;
|
|
}
|
|
|
|
if (!shouldRemove(entry.name)) {
|
|
continue;
|
|
}
|
|
|
|
rmSync(path, { force: true });
|
|
removed.push(relative(root, path));
|
|
}
|
|
}
|
|
|
|
walk(root);
|
|
|
|
if (removed.length === 0) {
|
|
console.log("No local artifacts found.");
|
|
} else {
|
|
console.log(`Removed ${removed.length} local artifact${removed.length === 1 ? "" : "s"}:`);
|
|
for (const file of removed) {
|
|
console.log(`- ${file}`);
|
|
}
|
|
}
|