Run client typecheck before vitest in npm test.

Duplicate keys in strings.ts were green under vitest and red only on build. Drop the self file: dependency loop so npm test is enough.
This commit is contained in:
Leonid Pershin
2026-08-20 12:57:16 +03:00
parent 9a6cbff55a
commit 45059b927f
7 changed files with 136 additions and 24 deletions
+38
View File
@@ -0,0 +1,38 @@
// `tsc -b && vitest run` on Windows npm (tsc.cmd) can drop the typecheck exit code.
import { spawnSync } from 'node:child_process';
import { createRequire } from 'node:module';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
const clientRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
const require = createRequire(import.meta.url);
const win = process.platform === 'win32';
function statusOf(result) {
if (result.error) {
console.error(result.error);
return 1;
}
return result.status ?? 1;
}
const typecheck = statusOf(
spawnSync(process.execPath, [require.resolve('typescript/bin/tsc'), '-b'], {
cwd: clientRoot,
stdio: 'inherit',
}),
);
if (typecheck !== 0) {
process.exit(typecheck);
}
const vitest = path.join(clientRoot, 'node_modules', '.bin', win ? 'vitest.cmd' : 'vitest');
process.exit(
statusOf(
spawnSync(vitest, ['run', ...process.argv.slice(2)], {
cwd: clientRoot,
stdio: 'inherit',
shell: win,
}),
),
);