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

Function plainExec

src/spec-common/commonUtils.ts:295–326  ·  view source on GitHub ↗
(defaultCwd: string | undefined)

Source from the content-addressed store, hash-verified

293};
294
295export function plainExec(defaultCwd: string | undefined): ExecFunction {
296 return async function (params: ExecParameters): Promise<Exec> {
297 const { cmd, args, stdio, output } = params;
298
299 const text = `Run: ${cmd} ${(args || []).join(' ').replace(/\n.*/g, '')}`;
300 const start = output.start(text);
301
302 const cwd = params.cwd || defaultCwd;
303 const env = params.env ? { ...process.env, ...params.env } : process.env;
304 const exec = await findLocalWindowsExecutable(cmd, cwd, env, output);
305 const p = cp.spawn(exec, args, { cwd, env, stdio: stdio as any, windowsHide: true });
306
307 return {
308 stdin: p.stdin,
309 stdout: p.stdout,
310 stderr: p.stderr,
311 exit: new Promise((resolve, reject) => {
312 p.once('error', err => {
313 output.stop(text, start);
314 reject(err);
315 });
316 p.once('close', (code, signal) => {
317 output.stop(text, start);
318 resolve({ code, signal });
319 });
320 }),
321 async terminate() {
322 p.kill('SIGKILL');
323 }
324 };
325 };
326}
327
328export async function plainPtyExec(defaultCwd: string | undefined, loadNativeModule: <T>(moduleName: string) => Promise<T | undefined>, allowInheritTTY: boolean): Promise<PtyExecFunction> {
329 const pty = await loadNativeModule<typeof ptyType>('node-pty');

Callers 7

getCLIHostFunction · 0.90
getCredentialFromHelperFunction · 0.90
launchShellServerFunction · 0.90
shellBufferExecFunction · 0.90
plainPtyExecFunction · 0.85
getLocalUsernameFunction · 0.85

Calls 4

resolveFunction · 0.85
startMethod · 0.80
stopMethod · 0.80

Tested by 1

launchShellServerFunction · 0.72