Viewing is open to everyone. Downloading and starring need a GitHub sign-in. Sign in with GitHub

check.mjs

v0.1.0-build.85 Latest Commit ede38f5

Size
1.0 KB
Lines
24
Language
javascript
SHA-256
3040c811047c…
View on GitHub

Sign in with GitHub to download. Each download is recorded with your GitHub username.

1// `node --check` every JavaScript file of the SDK (and, with --dist, require
2// that dist/ is assembled, so `npm pack` never ships an unbuilt package).
3import { execFileSync } from 'node:child_process';
4import { existsSync, readdirSync } from 'node:fs';
5import { dirname, join, resolve } from 'node:path';
6import { fileURLToPath } from 'node:url';
7
8const root = resolve(dirname(fileURLToPath(import.meta.url)), '..');
9const files = [];
10for (const dir of ['js', 'scripts', 'test', 'dist']) {
11 const d = join(root, dir);
12 if (!existsSync(d)) continue;
13 for (const f of readdirSync(d)) if (/\.(mjs|js)$/.test(f)) files.push(join(d, f));
14}
15for (const f of files) execFileSync(process.execPath, ['--check', f], { stdio: 'inherit' });
16console.log(`node --check: ${files.length} files OK`);
17if (process.argv.includes('--dist')) {
18 for (const f of ['ckey.mjs', 'ckey-core.mjs', 'ckey.wasm', 'ckey.d.ts']) {
19 if (!existsSync(join(root, 'dist', f))) {
20 console.error(`dist/${f} is missing: run npm run build first`);
21 process.exit(1);
22 }
23 }
24}