@@ -20,7 +20,10 @@ export const OVERRIDE_JAVA_AGENT = path.join(OVERRIDES_DIR, JAVA_AGENT_JAR);
2020export function getTerminalEnvVars (
2121 proxyPort : number ,
2222 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' ,
2427 targetEnvConfig : {
2528 httpToolkitIp ?: string ,
2629 overridePath ?: string ,
@@ -34,6 +37,17 @@ export function getTerminalEnvVars(
3437 ...targetEnvConfig
3538 } ;
3639
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+
3751 const pathVarSeparator = targetPlatform === 'win32' ? ';' : ':' ;
3852 const joinPath = targetPlatform === 'win32' ? path . win32 . join : path . posix . join ;
3953
@@ -96,33 +110,33 @@ export function getTerminalEnvVars(
96110
97111 // Prepend our bin overrides into $PATH
98112 'PATH' : `${ binPath } ${ pathVarSeparator } ${
99- currentEnv == 'runtime-inherit' ? '$ PATH' : currentEnv . PATH
113+ runtimeInherit ? runtimeInherit ( ' PATH') : currentEnv . PATH
100114 } `,
101115
102116 // Prepend our Ruby gem overrides into $LOAD_PATH
103- 'RUBYLIB' : currentEnv === 'runtime-inherit'
104- ? `${ rubyGemsPath } :$RUBYLIB`
117+ 'RUBYLIB' : runtimeInherit
118+ ? `${ rubyGemsPath } :${ runtimeInherit ( ' RUBYLIB' ) } `
105119 : ! ! currentEnv . RUBYLIB
106120 ? `${ rubyGemsPath } :${ currentEnv . RUBYLIB } `
107121 : rubyGemsPath ,
108122
109123 // Prepend our Python package overrides into $PYTHONPATH
110- 'PYTHONPATH' : currentEnv === 'runtime-inherit'
111- ? `${ pythonPath } :$PYTHONPATH`
124+ 'PYTHONPATH' : runtimeInherit
125+ ? `${ pythonPath } :${ runtimeInherit ( ' PYTHONPATH' ) } `
112126 : currentEnv . PYTHONPATH
113127 ? `${ pythonPath } :${ currentEnv . PYTHONPATH } `
114128 : pythonPath ,
115129
116130 // We use $NODE_OPTIONS to prepend our script into node. Notably this drops existing
117131 // env values, when using our env, because _our_ NODE_OPTIONS aren't meant for
118132 // 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 } `
121135 : nodePrependOption ,
122136
123137 // 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 } `
126140 : currentEnv . JAVA_TOOL_OPTIONS
127141 ? `${ currentEnv . JAVA_TOOL_OPTIONS } ${ javaAgentOption } `
128142 : javaAgentOption ,
0 commit comments