mirror of
https://github.com/nimbold/Firelink.git
synced 2026-07-26 12:08:27 +00:00
f603b74a99
Add target-aware engine provisioning, platform package configs, and CI/release verification for macOS arm64, Windows x64, and Linux AppImage.
63 lines
1.7 KiB
JavaScript
63 lines
1.7 KiB
JavaScript
#!/usr/bin/env node
|
|
import { spawn } from 'node:child_process';
|
|
import path from 'node:path';
|
|
|
|
function argValue(name) {
|
|
const index = process.argv.indexOf(name);
|
|
return index >= 0 ? process.argv[index + 1] : undefined;
|
|
}
|
|
|
|
const executableArg = argValue('--executable');
|
|
if (!executableArg) {
|
|
console.error('Pass --executable <path>.');
|
|
process.exit(1);
|
|
}
|
|
const executable = path.resolve(executableArg);
|
|
|
|
const child = spawn(executable, [], {
|
|
cwd: process.env.RUNNER_TEMP || process.env.TMPDIR || process.cwd(),
|
|
detached: process.platform !== 'win32',
|
|
stdio: ['ignore', 'pipe', 'pipe']
|
|
});
|
|
let stderr = '';
|
|
let spawnError = null;
|
|
child.on('error', error => {
|
|
spawnError = error;
|
|
});
|
|
child.stderr.on('data', data => {
|
|
stderr += data.toString();
|
|
});
|
|
|
|
let readyPort = null;
|
|
for (let attempt = 0; attempt < 40 && readyPort === null; attempt += 1) {
|
|
for (let port = 6412; port <= 6422; port += 1) {
|
|
try {
|
|
const response = await fetch(`http://127.0.0.1:${port}/ping`);
|
|
if (response.headers.get('x-firelink-server') === '1') {
|
|
readyPort = port;
|
|
break;
|
|
}
|
|
} catch {}
|
|
}
|
|
if (readyPort === null) {
|
|
await new Promise(resolve => setTimeout(resolve, 250));
|
|
}
|
|
}
|
|
|
|
if (process.platform === 'win32') {
|
|
spawn('taskkill', ['/pid', String(child.pid), '/t', '/f'], { stdio: 'ignore' });
|
|
} else {
|
|
try {
|
|
process.kill(-child.pid, 'SIGTERM');
|
|
} catch {
|
|
child.kill('SIGTERM');
|
|
}
|
|
}
|
|
|
|
if (readyPort === null) {
|
|
const detail = spawnError?.message || stderr.slice(-1000);
|
|
console.error(`Packaged Firelink did not expose extension server. ${detail}`);
|
|
process.exit(1);
|
|
}
|
|
console.log(`Packaged Firelink smoke passed on 127.0.0.1:${readyPort}`);
|