( shell, names, execFile = NodeChildProcess.execFileSync, )
| 303 | ) => Partial<Record<string, string>>; |
| 304 | |
| 305 | export const readEnvironmentFromLoginShell: ShellEnvironmentReader = ( |
| 306 | shell, |
| 307 | names, |
| 308 | execFile = NodeChildProcess.execFileSync, |
| 309 | ) => { |
| 310 | if (names.length === 0) { |
| 311 | return {}; |
| 312 | } |
| 313 | |
| 314 | const output = execFile(shell, ["-ilc", buildEnvironmentCaptureCommand(names)], { |
| 315 | encoding: "utf8", |
| 316 | timeout: 5000, |
| 317 | }); |
| 318 | |
| 319 | const environment: Partial<Record<string, string>> = {}; |
| 320 | for (const name of names) { |
| 321 | const value = extractEnvironmentValue(output, name); |
| 322 | if (value !== undefined) { |
| 323 | environment[name] = value; |
| 324 | } |
| 325 | } |
| 326 | |
| 327 | return environment; |
| 328 | }; |
| 329 | |
| 330 | export type WindowsShellEnvironmentReader = ( |
| 331 | names: ReadonlyArray<string>, |
no test coverage detected