({
port,
mountPoint,
env = {},
}: {
port: number;
mountPoint: string;
env?: Record<string, string>;
})
| 355 | }); |
| 356 | |
| 357 | async function startComputerd({ |
| 358 | port, |
| 359 | mountPoint, |
| 360 | env = {}, |
| 361 | }: { |
| 362 | port: number; |
| 363 | mountPoint: string; |
| 364 | env?: Record<string, string>; |
| 365 | }) { |
| 366 | const child = spawn(cliPath, { |
| 367 | cwd: packageRoot, |
| 368 | env: { ...process.env, MOUNT_POINT: mountPoint, PORT: String(port), ...env }, |
| 369 | stdio: ["ignore", "pipe", "pipe"], |
| 370 | }); |
| 371 | |
| 372 | let stdout = ""; |
| 373 | let stderr = ""; |
| 374 | child.stdout.setEncoding("utf8"); |
| 375 | child.stderr.setEncoding("utf8"); |
| 376 | child.stdout.on("data", (chunk) => { |
| 377 | stdout += chunk; |
| 378 | }); |
| 379 | child.stderr.on("data", (chunk) => { |
| 380 | stderr += chunk; |
| 381 | }); |
| 382 | |
| 383 | onTestFinished(async () => { |
| 384 | await stopProcess(child); |
| 385 | await fs.rm(mountPoint, { recursive: true, force: true }); |
| 386 | }); |
| 387 | |
| 388 | await waitForHTTPOK(`http://127.0.0.1:${port}/health`, child, () => stderr || stdout); |
| 389 | return child; |
| 390 | } |
| 391 | |
| 392 | function getAvailablePort() { |
| 393 | return new Promise((resolve, reject) => { |
no test coverage detected