( ip: string, localDir: string, remoteParent: string, )
| 66 | * lands at `${remoteParent}/${basename(localDir)}`. |
| 67 | */ |
| 68 | export const pushDirAsTar = async ( |
| 69 | ip: string, |
| 70 | localDir: string, |
| 71 | remoteParent: string, |
| 72 | ): Promise<void> => { |
| 73 | const parent = dirname(localDir); |
| 74 | const base = basename(localDir); |
| 75 | const remote = `${SSHPASS} -p ${GUEST_PASS} ssh ${SSH_OPTS.join(" ")} ${GUEST_USER}@${ip} ${JSON.stringify( |
| 76 | `mkdir -p ${remoteParent} && tar xf - -C ${remoteParent}`, |
| 77 | )}`; |
| 78 | const pipeline = `tar cf - -C ${JSON.stringify(parent)} ${JSON.stringify(base)} | ${remote}`; |
| 79 | // oxlint-disable-next-line executor/no-try-catch-or-throw -- boundary: one retry over a flaky just-booted guest link |
| 80 | try { |
| 81 | await execFileP("sh", ["-c", pipeline], { maxBuffer: 16 * 1024 * 1024 }); |
| 82 | } catch { |
| 83 | await sleep(3000); |
| 84 | await execFileP("sh", ["-c", pipeline], { maxBuffer: 16 * 1024 * 1024 }); |
| 85 | } |
| 86 | }; |
| 87 | |
| 88 | const freePort = (): Promise<number> => |
| 89 | new Promise((resolve, reject) => { |
no test coverage detected