* Gets a process environment object with defaults that can be used for * spawning non-interactive child processes. * * Currently we enable `FORCE_COLOR` since non-interactive spawn's with * non-inherited `stdio` will not have colors enabled due to a missing TTY.
( userProvidedEnv?: NodeJS.ProcessEnv, )
| 168 | * non-inherited `stdio` will not have colors enabled due to a missing TTY. |
| 169 | */ |
| 170 | function getEnvironmentForNonInteractiveCommand( |
| 171 | userProvidedEnv?: NodeJS.ProcessEnv, |
| 172 | ): NodeJS.ProcessEnv { |
| 173 | // Pass through the color level from the TTY/process performing the `spawn` call. |
| 174 | const forceColorValue = |
| 175 | supportsColor.stdout !== false ? supportsColor.stdout.level.toString() : undefined; |
| 176 | |
| 177 | return {FORCE_COLOR: forceColorValue, ...(userProvidedEnv ?? process.env)}; |
| 178 | } |
| 179 | |
| 180 | /** |
| 181 | * Process the ChildProcess object created by an async command. |