24 lines
1000 B
JavaScript
24 lines
1000 B
JavaScript
// Every browser file must parse: unit tests never load app.js, so a stray quote in a
|
|
// translation string would otherwise only show up as a blank page.
|
|
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { spawnSync } from "node:child_process";
|
|
import { copyFileSync, mkdtempSync, readdirSync, rmSync } from "node:fs";
|
|
import { tmpdir } from "node:os";
|
|
import { join } from "node:path";
|
|
|
|
test("every file in src/ parses as JavaScript", () => {
|
|
const src = new URL("../src/", import.meta.url).pathname;
|
|
const dir = mkdtempSync(join(tmpdir(), "rc-syntax-"));
|
|
try {
|
|
const bad = readdirSync(src).filter((name) => name.endsWith(".js")).filter((name) => {
|
|
const copy = join(dir, name.replace(/\.js$/, ".mjs"));
|
|
copyFileSync(join(src, name), copy);
|
|
return spawnSync(process.execPath, ["--check", copy], { encoding: "utf8" }).status !== 0;
|
|
});
|
|
assert.deepEqual(bad, []);
|
|
} finally {
|
|
rmSync(dir, { recursive: true, force: true });
|
|
}
|
|
});
|