23 lines
832 B
JavaScript
23 lines
832 B
JavaScript
// Vérif syntaxe de tous les .js (zéro dépendance, rapide sur le Pi)
|
|
import { readdirSync, statSync } from 'node:fs';
|
|
import { join } from 'node:path';
|
|
import { execFileSync } from 'node:child_process';
|
|
|
|
const roots = ['src', 'scripts', 'test', 'public'];
|
|
const files = [];
|
|
const walk = (dir) => {
|
|
for (const name of readdirSync(dir)) {
|
|
const p = join(dir, name);
|
|
if (statSync(p).isDirectory()) walk(p);
|
|
else if (p.endsWith('.js')) files.push(p);
|
|
}
|
|
};
|
|
for (const r of roots) { try { walk(r); } catch { /* dossier absent */ } }
|
|
|
|
let failed = 0;
|
|
for (const f of files) {
|
|
try { execFileSync(process.execPath, ['--check', f], { stdio: 'pipe' }); }
|
|
catch (e) { failed++; console.error(`✗ ${f}\n${e.stderr}`); }
|
|
}
|
|
console.log(`${files.length - failed}/${files.length} fichiers OK`);
|
|
process.exit(failed ? 1 : 0);
|