diff --git a/package.json b/package.json index d3d29e5..361aa81 100644 --- a/package.json +++ b/package.json @@ -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/", diff --git a/scripts/check-build-artifacts.mjs b/scripts/check-build-artifacts.mjs new file mode 100644 index 0000000..1b8a032 --- /dev/null +++ b/scripts/check-build-artifacts.mjs @@ -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.');