36 lines
1.5 KiB
JavaScript
36 lines
1.5 KiB
JavaScript
/*
|
|||
|
|
* build-win.cjs — build the Windows x64 installer. Works on Windows AND on macOS: electron-builder
|
||
|
|
* fetches its own mac build of wine for the few Windows-only steps, so the laptop can produce the
|
||
|
|
* exact installer the stage PC installs.
|
||
|
|
*
|
||
|
|
* npm run build:win
|
||
|
|
*
|
||
|
|
* Two things this wrapper exists to guarantee:
|
||
|
|
*
|
||
|
|
* - --x64. electron-builder otherwise targets the HOST architecture, so on an Apple Silicon Mac a
|
||
|
|
* plain `electron-builder --win` quietly produces an arm64 build that the stage PC cannot run.
|
||
|
|
* - a clean signing environment. There is no code-signing certificate. electron-builder aborts on
|
||
|
|
* an EMPTY WIN_CSC_LINK ("Env WIN_CSC_LINK is not correct"), so those variables are removed
|
||
|
|
* rather than blanked, and identity auto-discovery is turned off.
|
||
|
|
*/
|
||
|
|
const { spawnSync } = require('child_process');
|
||
|
|
const path = require('path');
|
||
|
|
|
||
|
|
const env = { ...process.env, CSC_IDENTITY_AUTO_DISCOVERY: 'false' };
|
||
|
|
for (const key of ['CSC_LINK', 'WIN_CSC_LINK', 'CSC_KEY_PASSWORD', 'WIN_CSC_KEY_PASSWORD', 'CSC_KEYCHAIN']) {
|
||
|
|
delete env[key];
|
||
|
|
}
|
||
|
|
|
||
|
|
const extra = process.argv.slice(2);
|
||
|
|
const args = ['electron-builder', '--win', '--x64', ...extra];
|
||
|
|
|
||
|
|
console.log(`Building the Windows x64 installer on ${process.platform}…`);
|
||
|
|
const r = spawnSync(process.platform === 'win32' ? 'npx.cmd' : 'npx', args, {
|
||
|
|
cwd: path.join(__dirname, '..'),
|
||
|
|
env,
|
||
|
|
stdio: 'inherit',
|
||
|
|
shell: process.platform === 'win32'
|
||
|
|
});
|
||
|
|
if (r.error) { console.error('Build failed to start:', r.error.message); process.exit(1); }
|
||
|
|
process.exit(r.status === null ? 1 : r.status);
|