MCPcopy Index your code
hub / github.com/devcontainers/cli / dockerExecFunction

Function dockerExecFunction

src/spec-shutdown/dockerUtils.ts:343–357  ·  view source on GitHub ↗
(params: DockerCLIParameters | PartialExecParameters | DockerResolverParameters, containerName: string, user: string | undefined, allocatePtyIfPossible = false)

Source from the content-addressed store, hash-verified

341}
342
343export function dockerExecFunction(params: DockerCLIParameters | PartialExecParameters | DockerResolverParameters, containerName: string, user: string | undefined, allocatePtyIfPossible = false): ExecFunction {
344 return async function (execParams: ExecParameters): Promise<Exec> {
345 const { exec, cmd, args, env } = toExecParameters(params);
346 // Spawning without node-pty: `docker exec` only accepts -t if stdin is a TTY. (https://github.com/devcontainers/cli/issues/606)
347 const canAllocatePty = allocatePtyIfPossible && process.stdin.isTTY && execParams.stdio?.[0] === 'inherit';
348 const { argsPrefix, args: execArgs } = toDockerExecArgs(containerName, user, execParams, canAllocatePty);
349 return exec({
350 cmd,
351 args: (args || []).concat(execArgs),
352 env,
353 stdio: execParams.stdio,
354 output: replacingDockerExecLog(execParams.output, cmd, argsPrefix),
355 });
356 };
357}
358
359export 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');

Callers 4

launchShellServerFunction · 0.90
dockerPtyExecFunctionFunction · 0.85

Calls 4

toExecParametersFunction · 0.85
toDockerExecArgsFunction · 0.85
replacingDockerExecLogFunction · 0.85
execFunction · 0.50

Tested by 1

launchShellServerFunction · 0.72