chore: check build artifact consistency

Change-Id: I485ee9ef2eaf584a1c1fcf890ee85fb82a34a8fb
This commit is contained in:
wujunchen 2026-04-26 18:22:11 +08:00
parent 70f9a39cd7
commit 2364e62911
2 changed files with 20 additions and 0 deletions

View file

@ -5,6 +5,7 @@
"main": "main.js",
"scripts": {
"build": "node esbuild.config.mjs production",
"check:build-artifacts": "node scripts/check-build-artifacts.mjs",
"dev": "node esbuild.config.mjs watch",
"typecheck": "tsc --noEmit",
"lint": "biome check main.ts src/",

View file

@ -0,0 +1,19 @@
import { execFileSync } from 'node:child_process';
function diffMainJs() {
return execFileSync('git', ['diff', '--', 'main.js'], { encoding: 'utf8' });
}
const before = diffMainJs();
execFileSync('npm', ['run', 'build'], { stdio: 'inherit' });
const after = diffMainJs();
if (after !== before) {
console.error('\nmain.js is not in sync with the TypeScript source.');
console.error('Run `npm run build` and include the updated main.js in the same change.');
process.exit(1);
}
console.log('main.js is in sync with the TypeScript source.');