Makelore 2.0 initial clean snapshot
This commit is contained in:
59
scripts/run-electron-builder.mjs
Normal file
59
scripts/run-electron-builder.mjs
Normal file
@@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import { spawn } from 'node:child_process';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const ROOT = path.resolve(__dirname, '..');
|
||||
const ELECTRON_BUILDER_BIN = process.platform === 'win32'
|
||||
? path.join(ROOT, 'node_modules', '.bin', 'electron-builder.cmd')
|
||||
: path.join(ROOT, 'node_modules', '.bin', 'electron-builder');
|
||||
const args = process.argv.slice(2);
|
||||
|
||||
const publishingRelease = args.some((arg, index) => arg === '--publish' && args[index + 1] === 'always')
|
||||
|| args.includes('--publish=always');
|
||||
const releaseCredentialRequired = publishingRelease || process.env.MEOWA_RELEASE_KEY_REQUIRED === '1';
|
||||
if (releaseCredentialRequired && !process.env.MEOWART_API_KEY?.trim()) {
|
||||
console.error('[release] MEOWART_API_KEY is required for a Meowa-enabled release build.');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
function shellQuote(value) {
|
||||
return `'${String(value).replace(/'/g, `'\\''`)}'`;
|
||||
}
|
||||
|
||||
function spawnElectronBuilder() {
|
||||
if (process.platform === 'darwin') {
|
||||
const command = [
|
||||
'ulimit -n 65536 >/dev/null 2>&1 || ulimit -n 32768 >/dev/null 2>&1 || ulimit -n 16384 >/dev/null 2>&1 || true',
|
||||
`exec ${shellQuote(ELECTRON_BUILDER_BIN)}${args.length > 0 ? ` ${args.map(shellQuote).join(' ')}` : ''}`,
|
||||
].join('; ');
|
||||
|
||||
return spawn('/bin/bash', ['-lc', command], {
|
||||
cwd: ROOT,
|
||||
stdio: 'inherit',
|
||||
env: process.env,
|
||||
});
|
||||
}
|
||||
|
||||
return spawn(ELECTRON_BUILDER_BIN, args, {
|
||||
cwd: ROOT,
|
||||
stdio: 'inherit',
|
||||
env: process.env,
|
||||
shell: process.platform === 'win32',
|
||||
});
|
||||
}
|
||||
|
||||
const child = spawnElectronBuilder();
|
||||
child.on('exit', (code, signal) => {
|
||||
if (signal) {
|
||||
process.kill(process.pid, signal);
|
||||
return;
|
||||
}
|
||||
process.exit(code ?? 1);
|
||||
});
|
||||
child.on('error', (error) => {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
});
|
||||
Reference in New Issue
Block a user