(command: string)
| 36 | }; |
| 37 | |
| 38 | const sshInvocation = (command: string): { command: string; args: ReadonlyArray<string> } => { |
| 39 | const host = process.env.E2E_CLI_VM_HOST; |
| 40 | if (!host) throw new Error("E2E_CLI_VM_HOST is not set"); |
| 41 | const os = guestOs(); |
| 42 | const wrapped = |
| 43 | os === "linux" ? `export XDG_RUNTIME_DIR=/run/user/$(id -u); ${command}` : command; |
| 44 | const keyPath = process.env.E2E_CLI_SSH_KEY; |
| 45 | const user = os === "windows" ? "Administrator" : "admin"; |
| 46 | return keyPath |
| 47 | ? { command: "ssh", args: ["-i", keyPath, ...SSH_OPTS, `${user}@${host}`, wrapped] } |
| 48 | : { |
| 49 | command: process.env.E2E_SSHPASS_BIN ?? "/opt/homebrew/bin/sshpass", |
| 50 | args: ["-p", "admin", "ssh", ...SSH_OPTS, `${user}@${host}`, wrapped], |
| 51 | }; |
| 52 | }; |
| 53 | |
| 54 | const ssh = async (command: string): Promise<{ stdout: string; stderr: string; code: number }> => { |
| 55 | const invocation = sshInvocation(command); |
no test coverage detected