1
>
/*---------------------------------------------------------------------------------------------
environmentVariable.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 { IProcessEnvironment } from '../../../base/common/platform.js';
7
>
import { IWorkspaceFolderData } from '../../workspace/common/workspace.js';
8
>
9
>
export enum EnvironmentVariableMutatorType {
10
>
Replace = 1,
11
>
Append = 2,
12
>
Prepend = 3
13
>
}
14
>
export interface IEnvironmentVariableMutator {
15
>
readonly variable: string;
16
>
readonly value: string;
17
>
readonly type: EnvironmentVariableMutatorType;
18
>
readonly scope?: EnvironmentVariableScope;
19
>
readonly options?: IEnvironmentVariableMutatorOptions;
20
>
}
21
>
22
>
export interface IEnvironmentVariableCollectionDescription {
23
>
readonly description: string | undefined;
24
>
readonly scope?: EnvironmentVariableScope;
25
>
}
26
>
27
>
export interface IEnvironmentVariableMutatorOptions {
28
>
applyAtProcessCreation?: boolean;
29
>
applyAtShellIntegration?: boolean;
30
>
}
31
>
32
>
export type EnvironmentVariableScope = {
33
>
workspaceFolder?: IWorkspaceFolderData;
34
>
};
35
>
36
>
export interface IEnvironmentVariableCollection {
37
>
readonly map: ReadonlyMap<string, IEnvironmentVariableMutator>;
38
>
readonly descriptionMap?: ReadonlyMap<string, IEnvironmentVariableCollectionDescription>;
39
>
}
40
>
41
>
/** [variable, mutator] */
42
>
export type ISerializableEnvironmentVariableCollection = [string, IEnvironmentVariableMutator][];
43
>
44
>
export type ISerializableEnvironmentDescriptionMap = [string, IEnvironmentVariableCollectionDescription][];
45
>
export interface IExtensionOwnedEnvironmentDescriptionMutator extends IEnvironmentVariableCollectionDescription {
46
>
readonly extensionIdentifier: string;
47
>
}
48
>
49
>
/** [extension, collection, description] */
50
>
export type ISerializableEnvironmentVariableCollections = [string, ISerializableEnvironmentVariableCollection, ISerializableEnvironmentDescriptionMap][];
51
>
52
>
export interface IExtensionOwnedEnvironmentVariableMutator extends IEnvironmentVariableMutator {
53
>
readonly extensionIdentifier: string;
54
>
}
55
>
56
>
export interface IMergedEnvironmentVariableCollectionDiff {
57
>
added: ReadonlyMap<string, IExtensionOwnedEnvironmentVariableMutator[]>;
58
>
changed: ReadonlyMap<string, IExtensionOwnedEnvironmentVariableMutator[]>;
59
>
removed: ReadonlyMap<string, IExtensionOwnedEnvironmentVariableMutator[]>;
60
>
}
61
>
62
>
type VariableResolver = (str: string) => Promise<string>;
63
>
64
>
/**
65
>
* Represents an environment variable collection that results from merging several collections
66
>
* together.
67
>
*/
68
>
export interface IMergedEnvironmentVariableCollection {
69
>
readonly collections: ReadonlyMap<string, IEnvironmentVariableCollection>;
70
>
/**
71
>
* Gets the variable map for a given scope.
72
>
* @param scope The scope to get the variable map for. If undefined, the global scope is used.
73
>
*/
74
>
getVariableMap(scope: EnvironmentVariableScope | undefined): Map<string, IExtensionOwnedEnvironmentVariableMutator[]>;
75
>
/**
76
>
* Gets the description map for a given scope.
77
>
* @param scope The scope to get the description map for. If undefined, description map for the
78
>
* global scope is returned.
79
>
*/
80
>
getDescriptionMap(scope: EnvironmentVariableScope | undefined): Map<string, string | undefined>;
81
>
/**
82
>
* Applies this collection to a process environment.
83
>
* @param variableResolver An optional function to use to resolve variables within the
84
>
* environment values.
85
>
*/
86
>
applyToProcessEnvironment(env: IProcessEnvironment, scope: EnvironmentVariableScope | undefined, variableResolver?: VariableResolver): Promise<void>;
87
>
88
>
/**
89
>
* Generates a diff of this collection against another. Returns undefined if the collections are
90
>
* the same.
91
>
*/
92
>
diff(other: IMergedEnvironmentVariableCollection, scope: EnvironmentVariableScope | undefined): IMergedEnvironmentVariableCollectionDiff | undefined;
93
>
}