1
>
/*---------------------------------------------------------------------------------------------
shellEnv.ts
2
>
* Copyright (c) Microsoft Corporation. All rights reserved.
3
>
* Licensed under the MIT License. See License.txt in the project root for license information.
4
>
*--------------------------------------------------------------------------------------------*/
5
>
6
>
import { spawn } from 'child_process';
7
>
import { basename } from '../../../base/common/path.js';
8
>
import { localize } from '../../../nls.js';
9
>
import { CancellationToken, CancellationTokenSource } from '../../../base/common/cancellation.js';
10
>
import { toErrorMessage } from '../../../base/common/errorMessage.js';
11
>
import { CancellationError, isCancellationError } from '../../../base/common/errors.js';
12
>
import { IProcessEnvironment, isWindows, OS } from '../../../base/common/platform.js';
13
>
import { generateUuid } from '../../../base/common/uuid.js';
14
>
import { getSystemShell } from '../../../base/node/shell.js';
15
>
import { NativeParsedArgs } from '../../environment/common/argv.js';
16
>
import { isLaunchedFromCli } from '../../environment/node/argvHelper.js';
17
>
import { ILogService } from '../../log/common/log.js';
18
>
import { Promises } from '../../../base/common/async.js';
19
>
import { IConfigurationService } from '../../configuration/common/configuration.js';
20
>
import { clamp } from '../../../base/common/numbers.js';
21
>
22
>
let unixShellEnvPromise: Promise<typeof process.env> | undefined = undefined;
23
>
24
>
/**
25
>
* Resolves the shell environment by spawning a shell. This call will cache
26
>
* the shell spawning so that subsequent invocations use that cached result.
27
>
*
28
>
* Will throw an error if:
29
>
* - we hit a timeout of `MAX_SHELL_RESOLVE_TIME`
30
>
* - any other error from spawning a shell to figure out the environment
31
>
*/
32
export async function getResolvedShellEnv(configurationService: IConfigurationService, logService: ILogService, args: NativeParsedArgs, env: IProcessEnvironment): Promise<typeof process.env> {
33