| 48 | }; |
| 49 | |
| 50 | const sshInvocation = (command: string): { command: string; args: ReadonlyArray<string> } => { |
| 51 | const host = process.env.E2E_CLI_VM_HOST; |
| 52 | if (!host) throw new Error("E2E_CLI_VM_HOST is not set"); |
| 53 | const os = guestOs(); |
| 54 | const wrapped = |
| 55 | os === "linux" ? `export XDG_RUNTIME_DIR=/run/user/$(id -u); ${command}` : command; |
| 56 | const keyPath = process.env.E2E_CLI_SSH_KEY; |
| 57 | const user = os === "windows" ? "Administrator" : "admin"; |
| 58 | return keyPath |
| 59 | ? { command: "ssh", args: ["-i", keyPath, ...SSH_OPTS, `${user}@${host}`, wrapped] } |
| 60 | : { |
| 61 | command: process.env.E2E_SSHPASS_BIN ?? "/opt/homebrew/bin/sshpass", |
| 62 | args: ["-p", "admin", "ssh", ...SSH_OPTS, `${user}@${host}`, wrapped], |
| 63 | }; |
| 64 | }; |
| 65 | |
| 66 | const ssh = async (command: string): Promise<{ stdout: string; stderr: string; code: number }> => { |
| 67 | const invocation = sshInvocation(command); |