MCPcopy Index your code
hub / github.com/angular/dev-infra / spawn

Function spawn

ng-dev/utils/child-process.ts:122–135  ·  view source on GitHub ↗

* Spawns a given command with the specified arguments inside a shell. All process stdout * output is captured and returned as resolution on completion. Depending on the chosen * output mode, stdout/stderr output is also printed to the console, or only on error. * * @returns a Promise res

(command: string, args: string[], options: SpawnOptions = {})

Source from the content-addressed store, hash-verified

120 * rejects on command failure.
121 */
122 static spawn(command: string, args: string[], options: SpawnOptions = {}): Promise<SpawnResult> {
123 // Default shell to false to prevent OS command injection: with shell: true, Node.js
124 // internally joins command + args into a single string evaluated by /bin/sh, making
125 // shell metacharacters in args exploitable. Callers that genuinely require shell
126 // features (e.g. sourcing shell scripts) may explicitly pass shell: true.
127 const commandText = `${command} ${args.join(' ')}`;
128 const env = getEnvironmentForNonInteractiveCommand(options.env);
129
130 return processAsyncCmd(
131 commandText,
132 options,
133 _spawn(command, args, {...options, env, stdio: 'pipe'}),
134 );
135 }
136
137 /**
138 * Execs a given command with the specified arguments inside a shell. All process stdout

Callers

nothing calls this directly

Calls 2

processAsyncCmdFunction · 0.85

Tested by

no test coverage detected