(params: PartialPtyExecParameters | DockerResolverParameters, containerName: string, user: string | undefined, loadNativeModule: <T>(moduleName: string) => Promise<T | undefined>, allowInheritTTY: boolean)
| 357 | } |
| 358 | |
| 359 | export async function dockerPtyExecFunction(params: PartialPtyExecParameters | DockerResolverParameters, containerName: string, user: string | undefined, loadNativeModule: <T>(moduleName: string) => Promise<T | undefined>, allowInheritTTY: boolean): Promise<PtyExecFunction> { |
| 360 | const pty = await loadNativeModule<typeof ptyType>('node-pty'); |
| 361 | if (!pty) { |
| 362 | const plain = dockerExecFunction(params, containerName, user, true); |
| 363 | return plainExecAsPtyExec(plain, allowInheritTTY); |
| 364 | } |
| 365 | |
| 366 | return async function (execParams: PtyExecParameters): Promise<PtyExec> { |
| 367 | const { ptyExec, cmd, args, env } = toPtyExecParameters(params); |
| 368 | const { argsPrefix, args: execArgs } = toDockerExecArgs(containerName, user, execParams, true); |
| 369 | return ptyExec({ |
| 370 | cmd, |
| 371 | args: (args || []).concat(execArgs), |
| 372 | env, |
| 373 | output: replacingDockerExecLog(execParams.output, cmd, argsPrefix), |
| 374 | }); |
| 375 | }; |
| 376 | } |
| 377 | |
| 378 | function replacingDockerExecLog(original: Log, cmd: string, args: string[]) { |
| 379 | return replacingLog(original, `Run: ${cmd} ${(args || []).join(' ').replace(/\n.*/g, '')}`, 'Run in container:'); |
no test coverage detected