Run the CLI to completion, capturing stdout+stderr and the exit code.
(args: string[], env: Record<string, string> = {})
| 34 | |
| 35 | /** Run the CLI to completion, capturing stdout+stderr and the exit code. */ |
| 36 | function runCli(args: string[], env: Record<string, string> = {}): { code: number; output: string } { |
| 37 | try { |
| 38 | const output = execFileSync(process.execPath, [BIN, ...args], { |
| 39 | encoding: 'utf-8', |
| 40 | env: { ...BASE_ENV, ...env }, |
| 41 | stdio: ['ignore', 'pipe', 'pipe'], |
| 42 | }); |
| 43 | return { code: 0, output }; |
| 44 | } catch (err) { |
| 45 | const e = err as { status?: number; stdout?: string; stderr?: string }; |
| 46 | return { code: e.status ?? 1, output: `${e.stdout ?? ''}${e.stderr ?? ''}` }; |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | /** GET a path from a running viewer, with a valid loopback Host. */ |
| 51 | function get(port: number, requestPath: string): Promise<{ status: number; body: string }> { |
no outgoing calls
no test coverage detected