check.js 553 B

1234567891011121314
  1. import { readdirSync } from 'node:fs';
  2. import { join } from 'node:path';
  3. import { spawnSync } from 'node:child_process';
  4. let count = 0;
  5. for (const folder of ['src', 'public', 'extension', 'tests', 'scripts']) {
  6. for (const file of readdirSync(folder)) {
  7. if (!file.endsWith('.js')) continue;
  8. const path = join(folder, file), result = spawnSync(process.execPath, ['--check', path], { stdio: 'inherit' });
  9. if (result.status !== 0) process.exit(result.status || 1);
  10. count++;
  11. }
  12. }
  13. console.log(`Syntax checked ${count} JavaScript files.`);