( host: string, command: string, timeoutMs = SSH_TIMEOUT_MS, )
| 16 | } |
| 17 | |
| 18 | async function runSshCommand( |
| 19 | host: string, |
| 20 | command: string, |
| 21 | timeoutMs = SSH_TIMEOUT_MS, |
| 22 | ): Promise<{ stdout: string; stderr: string; exitCode: number }> { |
| 23 | const proc = Bun.spawn(['ssh', '-o', 'ConnectTimeout=10', host, command], { |
| 24 | stdout: 'pipe', |
| 25 | stderr: 'pipe', |
| 26 | }) |
| 27 | |
| 28 | const timer = setTimeout(() => proc.kill(), timeoutMs) |
| 29 | |
| 30 | try { |
| 31 | const [stdout, stderr] = await Promise.all([ |
| 32 | new Response(proc.stdout).text(), |
| 33 | new Response(proc.stderr).text(), |
| 34 | ]) |
| 35 | const exitCode = await proc.exited |
| 36 | return { stdout: stdout.trim(), stderr: stderr.trim(), exitCode } |
| 37 | } finally { |
| 38 | clearTimeout(timer) |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | function findLocalBinary(): string { |
| 43 | const projectRoot = resolve(import.meta.dir, '../..') |
no test coverage detected