@@ -20,7 +20,10 @@ export const OVERRIDE_JAVA_AGENT = path.join(OVERRIDES_DIR, JAVA_AGENT_JAR);
20
20
export function getTerminalEnvVars (
21
21
proxyPort : number ,
22
22
httpsConfig : { certPath : string } ,
23
- currentEnv : { [ key : string ] : string | undefined } | 'runtime-inherit' ,
23
+ currentEnv :
24
+ | { [ key : string ] : string | undefined }
25
+ | 'posix-runtime-inherit'
26
+ | 'powershell-runtime-inherit' ,
24
27
targetEnvConfig : {
25
28
httpToolkitIp ?: string ,
26
29
overridePath ?: string ,
@@ -34,6 +37,17 @@ export function getTerminalEnvVars(
34
37
...targetEnvConfig
35
38
} ;
36
39
40
+ const runtimeInherit = currentEnv === 'posix-runtime-inherit'
41
+ ? ( varName : string ) => `$${ varName } `
42
+ : currentEnv === 'powershell-runtime-inherit'
43
+ ? ( ( varName : string ) => `$env:${ varName } ` )
44
+ : undefined ;
45
+ currentEnv = ( runtimeInherit
46
+ ? { } // Reset the env if we're using runtime inheritance:
47
+ // Or use the real values we were given if not:
48
+ : currentEnv
49
+ ) as { [ key : string ] : string | undefined } ;
50
+
37
51
const pathVarSeparator = targetPlatform === 'win32' ? ';' : ':' ;
38
52
const joinPath = targetPlatform === 'win32' ? path . win32 . join : path . posix . join ;
39
53
@@ -96,33 +110,33 @@ export function getTerminalEnvVars(
96
110
97
111
// Prepend our bin overrides into $PATH
98
112
'PATH' : `${ binPath } ${ pathVarSeparator } ${
99
- currentEnv == 'runtime-inherit' ? '$ PATH' : currentEnv . PATH
113
+ runtimeInherit ? runtimeInherit ( ' PATH') : currentEnv . PATH
100
114
} `,
101
115
102
116
// Prepend our Ruby gem overrides into $LOAD_PATH
103
- 'RUBYLIB' : currentEnv === 'runtime-inherit'
104
- ? `${ rubyGemsPath } :$RUBYLIB`
117
+ 'RUBYLIB' : runtimeInherit
118
+ ? `${ rubyGemsPath } :${ runtimeInherit ( ' RUBYLIB' ) } `
105
119
: ! ! currentEnv . RUBYLIB
106
120
? `${ rubyGemsPath } :${ currentEnv . RUBYLIB } `
107
121
: rubyGemsPath ,
108
122
109
123
// Prepend our Python package overrides into $PYTHONPATH
110
- 'PYTHONPATH' : currentEnv === 'runtime-inherit'
111
- ? `${ pythonPath } :$PYTHONPATH`
124
+ 'PYTHONPATH' : runtimeInherit
125
+ ? `${ pythonPath } :${ runtimeInherit ( ' PYTHONPATH' ) } `
112
126
: currentEnv . PYTHONPATH
113
127
? `${ pythonPath } :${ currentEnv . PYTHONPATH } `
114
128
: pythonPath ,
115
129
116
130
// We use $NODE_OPTIONS to prepend our script into node. Notably this drops existing
117
131
// env values, when using our env, because _our_ NODE_OPTIONS aren't meant for
118
132
// subprocesses. Otherwise e.g. --max-http-header-size breaks old Node/Electron.
119
- 'NODE_OPTIONS' : currentEnv === 'runtime-inherit'
120
- ? `$NODE_OPTIONS ${ nodePrependOption } `
133
+ 'NODE_OPTIONS' : runtimeInherit
134
+ ? `${ runtimeInherit ( ' NODE_OPTIONS' ) } ${ nodePrependOption } `
121
135
: nodePrependOption ,
122
136
123
137
// Attach our Java agent to all launched Java processes:
124
- 'JAVA_TOOL_OPTIONS' : currentEnv === 'runtime-inherit'
125
- ? `$JAVA_TOOL_OPTIONS ${ javaAgentOption } `
138
+ 'JAVA_TOOL_OPTIONS' : runtimeInherit
139
+ ? `${ runtimeInherit ( ' JAVA_TOOL_OPTIONS' ) } ${ javaAgentOption } `
126
140
: currentEnv . JAVA_TOOL_OPTIONS
127
141
? `${ currentEnv . JAVA_TOOL_OPTIONS } ${ javaAgentOption } `
128
142
: javaAgentOption ,
0 commit comments