- 修正 self-improving-agent skill 的 repoPath,指向包含 SKILL.md 的子目录 - 强制 electron-builder 在 Windows 上识别 pnpm,避免 fallback 到 npm 导致依赖收集极慢 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
58 lines
1.7 KiB
JavaScript
58 lines
1.7 KiB
JavaScript
#!/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);
|
|
|
|
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,
|
|
// Force electron-builder to detect pnpm on Windows where the packageManager
|
|
// field is sometimes ignored and it falls back to npm (which chokes on
|
|
// pnpm's node_modules layout and becomes extremely slow).
|
|
npm_config_user_agent: process.env.npm_config_user_agent || 'pnpm/10.33.4',
|
|
},
|
|
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);
|
|
});
|