Skip to content

Commit

Permalink
Merge pull request #74811 from microsoft/roblou/disableShellEnv
Browse files Browse the repository at this point in the history
Allow disabling shell environment probe
  • Loading branch information
roblourens committed Jun 3, 2019
2 parents 7ad025b + 7e0f57e commit 3e8915c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/vs/code/electron-main/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ export class CodeApplication extends Disposable {

ipc.on('vscode:fetchShellEnv', (event: Event) => {
const webContents = event.sender;
getShellEnvironment(this.logService).then(shellEnv => {
getShellEnvironment(this.logService, this.environmentService).then(shellEnv => {
if (!webContents.isDestroyed()) {
webContents.send('vscode:acceptShellEnv', shellEnv);
}
Expand Down Expand Up @@ -657,7 +657,7 @@ export class CodeApplication extends Disposable {
historyMainService.onRecentlyOpenedChange(() => historyMainService.updateWindowsJumpList());

// Start shared process after a while
const sharedProcessSpawn = this._register(new RunOnceScheduler(() => getShellEnvironment(this.logService).then(userEnv => this.sharedProcess.spawn(userEnv)), 3000));
const sharedProcessSpawn = this._register(new RunOnceScheduler(() => getShellEnvironment(this.logService, this.environmentService).then(userEnv => this.sharedProcess.spawn(userEnv)), 3000));
sharedProcessSpawn.schedule();

// Helps application icon refresh after an update with new icon is installed (macOS)
Expand Down
8 changes: 6 additions & 2 deletions src/vs/code/node/shellEnv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { assign } from 'vs/base/common/objects';
import { generateUuid } from 'vs/base/common/uuid';
import { isWindows } from 'vs/base/common/platform';
import { ILogService } from 'vs/platform/log/common/log';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';

function getUnixShellEnvironment(logService: ILogService): Promise<typeof process.env> {
const promise = new Promise<typeof process.env>((resolve, reject) => {
Expand Down Expand Up @@ -89,9 +90,12 @@ let _shellEnv: Promise<typeof process.env>;
* This should only be done when Code itself is not launched
* from within a shell.
*/
export function getShellEnvironment(logService: ILogService): Promise<typeof process.env> {
export function getShellEnvironment(logService: ILogService, environmentService: IEnvironmentService): Promise<typeof process.env> {
if (_shellEnv === undefined) {
if (isWindows) {
if (environmentService.args['disable-user-env-probe']) {
logService.trace('getShellEnvironment: disable-user-env-probe set, skipping');
_shellEnv = Promise.resolve({});
} else if (isWindows) {
logService.trace('getShellEnvironment: runing on windows, skipping');
_shellEnv = Promise.resolve({});
} else if (process.env['VSCODE_CLI'] === '1') {
Expand Down
1 change: 1 addition & 0 deletions src/vs/platform/environment/common/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export interface ParsedArgs {
'driver'?: string;
'driver-verbose'?: boolean;
remote?: string;
'disable-user-env-probe'?: boolean;
}

export const IEnvironmentService = createDecorator<IEnvironmentService>('environmentService');
Expand Down

0 comments on commit 3e8915c

Please sign in to comment.