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

Function runSingleCommand

src/spec-node/utils.ts:562–593  ·  view source on GitHub ↗
(command: string | string[], name?: string)

Source from the content-addressed store, hash-verified

560 // Runs a command.
561 // Useful for the object syntax, where >1 command can be specified to run in parallel.
562 async function runSingleCommand(command: string | string[], name?: string) {
563 const updatedCommand = isWindows && Array.isArray(command) && command.length ?
564 [(command[0] || '').replace(/\//g, '\\'), ...command.slice(1)] :
565 command;
566 const args = typeof updatedCommand === 'string' ? [...shell, updatedCommand] : updatedCommand;
567 if (!args.length) {
568 return;
569 }
570
571 // 'name' is set when parallel execution syntax is used.
572 if (name) {
573 infoOutput.raw(`\x1b[1mRunning '${name}' from ${hookName}...\x1b[0m\r\n\r\n`);
574 } else {
575 infoOutput.raw(`\x1b[1mRunning the ${hookName} from devcontainer.json...\x1b[0m\r\n\r\n`);
576 }
577
578 // If we have a command name then the command is running in parallel and
579 // we need to hold output until the command is done so that the output
580 // doesn't get interleaved with the output of other commands.
581 const print = name ? 'end' : 'continuous';
582
583 await runCommand({
584 ptyExec: cliHost.ptyExec,
585 cmd: args[0],
586 args: args.slice(1),
587 env: dockerEnv,
588 output: infoOutput,
589 onDidInput,
590 print,
591 });
592 infoOutput.raw('\r\n');
593 }
594
595 let commands;
596 if (typeof userCommand === 'string' || Array.isArray(userCommand)) {

Callers 1

runInitializeCommandFunction · 0.70

Calls 2

runCommandFunction · 0.90
rawMethod · 0.80

Tested by

no test coverage detected