client/scripts/lint-packages.ts
Alois 3c7a28ceb2
Some checks failed
/ build-web (push) Failing after 2m19s
/ build-desktop (linux) (push) Failing after 2m7s
/ release (push) Has been cancelled
/ build-mobile (push) Has been cancelled
Reapply "(fix): now run builds in nix shell"
This reverts commit 10da530e9e.
2026-06-28 19:10:23 +02:00

48 lines
1.2 KiB
TypeScript

import { existsSync, readdirSync, statSync } from "fs";
import { join, relative } from "path";
import { execSync } from "child_process";
import { fileURLToPath } from "node:url";
import { dirname } from "node:path";
const _dirname = dirname(fileURLToPath(import.meta.url));
const rootDir = join(_dirname, "..");
const targetDirs = [join(rootDir, "packages"), join(rootDir, "apps")];
function getPackageDirs(dir: string): string[] {
const entries = readdirSync(dir);
const dirs: string[] = [];
for (const entry of entries) {
const fullPath = join(dir, entry);
if (!statSync(fullPath).isDirectory()) continue;
if (existsSync(join(fullPath, "package.json"))) {
dirs.push(fullPath);
continue;
}
dirs.push(...getPackageDirs(fullPath));
}
return dirs;
}
for (const targetDir of targetDirs) {
const packageDirs = getPackageDirs(targetDir);
for (const fullPath of packageDirs) {
const entry = relative(rootDir, fullPath);
console.log(`Linting ${entry}...`);
try {
execSync("bun run lint", { cwd: fullPath, stdio: "inherit" });
console.log(`${entry} linted successfully.`);
} catch {
console.error(`Failed to lint ${entry}.`);
process.exit(1);
}
}
}
console.log("Done!");