17 lines
630 B
JavaScript
17 lines
630 B
JavaScript
import { readdirSync } from 'node:fs';
|
|
import { join } from 'node:path';
|
|
import { spawnSync } from 'node:child_process';
|
|
|
|
function check(directory) {
|
|
for (const file of readdirSync(directory, { withFileTypes: true })) {
|
|
const path = join(directory, file.name);
|
|
if (file.isDirectory()) check(path);
|
|
else if (file.name.endsWith('.js')) {
|
|
const result = spawnSync(process.execPath, ['--check', path], { stdio: 'inherit' });
|
|
if (result.status !== 0) process.exit(1);
|
|
}
|
|
}
|
|
}
|
|
for (const directory of ['src', 'public', 'scripts', 'test']) check(directory);
|
|
console.log('JavaScript syntax checks passed.');
|