* 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 = {})
| 120 | return {status, stdout, stderr}; |
| 121 | } |
| 122 | |
| 123 | throw new Error(sanitize(stderr)); |
| 124 | } |
| 125 | |
| 126 | /** |
| 127 | * Spawns a given command with the specified arguments inside a shell. All process stdout |
| 128 | * output is captured and returned as resolution on completion. Depending on the chosen |
| 129 | * output mode, stdout/stderr output is also printed to the console, or only on error. |
| 130 | * |
| 131 | * @returns a Promise resolving with captured stdout and stderr on success. The promise |
| 132 | * rejects on command failure. |
| 133 | */ |
| 134 | static spawn(command: string, args: string[], options: SpawnOptions = {}): Promise<SpawnResult> { |
| 135 | // Default shell to false to prevent OS command injection: with shell: true, Node.js |
| 136 | // internally joins command + args into a single string evaluated by /bin/sh, making |
| 137 | // shell metacharacters in args exploitable. Callers that genuinely require shell |
| 138 | // features (e.g. sourcing shell scripts) may explicitly pass shell: true. |
nothing calls this directly
no test coverage detected