1
>
/*---------------------------------------------------------------------------------------------
terminalEnvironment.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 * as os from 'os';
7
>
import { FileAccess } from '../../../base/common/network.js';
8
>
import * as path from '../../../base/common/path.js';
9
>
import { IProcessEnvironment, isMacintosh, isWindows } from '../../../base/common/platform.js';
10
>
import * as process from '../../../base/common/process.js';
11
>
import { format } from '../../../base/common/strings.js';
12
>
import { ILogService } from '../../log/common/log.js';
13
>
import { IProductService } from '../../product/common/productService.js';
14
>
import { IShellLaunchConfig, ITerminalEnvironment, ITerminalProcessOptions, ShellIntegrationInjectionFailureReason } from '../common/terminal.js';
15
>
import { EnvironmentVariableMutatorType } from '../common/environmentVariable.js';
16
>
import { deserializeEnvironmentVariableCollections } from '../common/environmentVariableShared.js';
17
>
import { MergedEnvironmentVariableCollection } from '../common/environmentVariableCollection.js';
18
>
import { chmod, realpathSync, mkdirSync } from 'fs';
19
>
import { promisify } from 'util';
20
>
import { isString, SingleOrMany } from '../../../base/common/types.js';
21
>
import { getWindowsBuildNumberAsync } from '../../../base/node/windowsVersion.js';
22
>
23
>
export interface IShellIntegrationConfigInjection {
24
>
readonly type: 'injection';
25
>
/**
26
>
* A new set of arguments to use.
27
>
*/
28
>
readonly newArgs: string[] | undefined;
29
>
/**
30
>
* An optional environment to mixing to the real environment.
31
>
*/
32
>
readonly envMixin?: IProcessEnvironment;
33
>
/**
34
>
* An optional array of files to copy from `source` to `dest`.
35
>
*/
36
>
readonly filesToCopy?: {
37
>
source: string;
38
>
dest: string;
39
>
}[];
40
>
}
41
>
42
>
export interface IShellIntegrationInjectionFailure {
43
>
readonly type: 'failure';
44
>
readonly reason: ShellIntegrationInjectionFailureReason;
45
>
}
46
>
47
>
/**
48
>
* For a given shell launch config, returns arguments to replace and an optional environment to
49
>
* mixin to the SLC's environment to enable shell integration. This must be run within the context
50
>
* that creates the process to ensure accuracy. Returns undefined if shell integration cannot be
51
>
* enabled.
52
>
*/
53
export async function getShellIntegrationInjection(
54
shellLaunchConfig: IShellLaunchConfig,