33 * Licensed under the MIT License. See License.txt in the project root for license information.
44 *--------------------------------------------------------------------------------------------*/
55
6- import * as cp from 'child_process' ;
6+ import { spawn } from 'child_process' ;
77import { generateUuid } from 'vs/base/common/uuid' ;
88import { isWindows } from 'vs/base/common/platform' ;
99import { ILogService } from 'vs/platform/log/common/log' ;
@@ -30,7 +30,7 @@ function getUnixShellEnvironment(logService: ILogService): Promise<typeof proces
3030 logService . trace ( 'getUnixShellEnvironment#env' , env ) ;
3131 logService . trace ( 'getUnixShellEnvironment#spawn' , command ) ;
3232
33- const child = cp . spawn ( process . env . SHELL ! , [ '-ilc' , command ] , {
33+ const child = spawn ( process . env . SHELL ! , [ '-ilc' , command ] , {
3434 detached : true ,
3535 stdio : [ 'ignore' , 'pipe' , process . stderr ] ,
3636 env
@@ -82,30 +82,29 @@ function getUnixShellEnvironment(logService: ILogService): Promise<typeof proces
8282 return promise . catch ( ( ) => ( { } ) ) ;
8383}
8484
85-
86- let _shellEnv : Promise < typeof process . env > ;
85+ let shellEnvPromise : Promise < typeof process . env > | undefined = undefined ;
8786
8887/**
8988 * We need to get the environment from a user's shell.
9089 * This should only be done when Code itself is not launched
9190 * from within a shell.
9291 */
9392export function getShellEnvironment ( logService : ILogService , environmentService : INativeEnvironmentService ) : Promise < typeof process . env > {
94- if ( _shellEnv === undefined ) {
93+ if ( ! shellEnvPromise ) {
9594 if ( environmentService . args [ 'disable-user-env-probe' ] ) {
9695 logService . trace ( 'getShellEnvironment: disable-user-env-probe set, skipping' ) ;
97- _shellEnv = Promise . resolve ( { } ) ;
96+ shellEnvPromise = Promise . resolve ( { } ) ;
9897 } else if ( isWindows ) {
9998 logService . trace ( 'getShellEnvironment: running on Windows, skipping' ) ;
100- _shellEnv = Promise . resolve ( { } ) ;
99+ shellEnvPromise = Promise . resolve ( { } ) ;
101100 } else if ( process . env [ 'VSCODE_CLI' ] === '1' && process . env [ 'VSCODE_FORCE_USER_ENV' ] !== '1' ) {
102101 logService . trace ( 'getShellEnvironment: running on CLI, skipping' ) ;
103- _shellEnv = Promise . resolve ( { } ) ;
102+ shellEnvPromise = Promise . resolve ( { } ) ;
104103 } else {
105104 logService . trace ( 'getShellEnvironment: running on Unix' ) ;
106- _shellEnv = getUnixShellEnvironment ( logService ) ;
105+ shellEnvPromise = getUnixShellEnvironment ( logService ) ;
107106 }
108107 }
109108
110- return _shellEnv ;
109+ return shellEnvPromise ;
111110}
0 commit comments