Skip to content

Commit 64eb716

Browse files
committed
env - fully qualify our own variables
1 parent c03bc42 commit 64eb716

File tree

22 files changed

+79
-75
lines changed

22 files changed

+79
-75
lines changed

src/bootstrap-fork.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ if (process.env['VSCODE_INJECT_NODE_MODULE_LOOKUP_PATH']) {
2323
}
2424

2525
// Configure: pipe logging to parent process
26-
if (!!process.send && process.env.PIPE_LOGGING === 'true') {
26+
if (!!process.send && process.env['VSCODE_PIPE_LOGGING'] === 'true') {
2727
pipeLoggingToParent();
2828
}
2929

@@ -41,7 +41,7 @@ if (process.env['VSCODE_PARENT_PID']) {
4141
configureCrashReporter();
4242

4343
// Load AMD entry point
44-
require('./bootstrap-amd').load(process.env['AMD_ENTRYPOINT']);
44+
require('./bootstrap-amd').load(process.env['VSCODE_AMD_ENTRYPOINT']);
4545

4646

4747
//#region Helpers
@@ -82,7 +82,7 @@ function pipeLoggingToParent() {
8282

8383
// Add the stack trace as payload if we are told so. We remove the message and the 2 top frames
8484
// to start the stacktrace where the console message was being written
85-
if (process.env.VSCODE_LOG_STACK === 'true') {
85+
if (process.env['VSCODE_LOG_STACK'] === 'true') {
8686
const stack = new Error().stack;
8787
if (stack) {
8888
argsArray.push({ __$stack: stack.split('\n').slice(3).join('\n') });
@@ -152,7 +152,7 @@ function pipeLoggingToParent() {
152152
* @param {'log' | 'warn' | 'error'} severity
153153
*/
154154
function wrapConsoleMethod(method, severity) {
155-
if (process.env.VSCODE_LOG_NATIVE === 'true') {
155+
if (process.env['VSCODE_LOG_NATIVE'] === 'true') {
156156
const original = console[method];
157157
console[method] = function () {
158158
safeSendConsoleMessage(severity, safeToArray(arguments));
@@ -168,12 +168,12 @@ function pipeLoggingToParent() {
168168
}
169169

170170
// Pass console logging to the outside so that we have it in the main side if told so
171-
if (process.env.VERBOSE_LOGGING === 'true') {
171+
if (process.env['VSCODE_VERBOSE_LOGGING'] === 'true') {
172172
wrapConsoleMethod('info', 'log');
173173
wrapConsoleMethod('log', 'log');
174174
wrapConsoleMethod('warn', 'warn');
175175
wrapConsoleMethod('error', 'error');
176-
} else if (process.env.VSCODE_LOG_NATIVE !== 'true') {
176+
} else if (process.env['VSCODE_LOG_NATIVE'] !== 'true') {
177177
console.log = function () { /* ignore */ };
178178
console.warn = function () { /* ignore */ };
179179
console.info = function () { /* ignore */ };
@@ -209,7 +209,7 @@ function terminateWhenParentTerminates() {
209209
}
210210

211211
function configureCrashReporter() {
212-
const crashReporterOptionsRaw = process.env['CRASH_REPORTER_START_OPTIONS'];
212+
const crashReporterOptionsRaw = process.env['VSCODE_CRASH_REPORTER_START_OPTIONS'];
213213
if (typeof crashReporterOptionsRaw === 'string') {
214214
try {
215215
const crashReporterOptions = JSON.parse(crashReporterOptionsRaw);

src/vs/base/common/path.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const CHAR_QUESTION_MARK = 63; /* ? */
4343

4444
class ErrorInvalidArgType extends Error {
4545
code: 'ERR_INVALID_ARG_TYPE';
46-
constructor(name: string, expected: string, actual: any) {
46+
constructor(name: string, expected: string, actual: unknown) {
4747
// determiner: 'must be' or 'must not be'
4848
let determiner;
4949
if (typeof expected === 'string' && expected.indexOf('not ') === 0) {
@@ -215,7 +215,7 @@ export const win32: IPath = {
215215
// absolute path, get cwd for that drive, or the process cwd if
216216
// the drive cwd is not available. We're sure the device is not
217217
// a UNC path at this points, because UNC paths are always absolute.
218-
path = (process.env as any)[`=${resolvedDevice}`] || process.cwd();
218+
path = process.env[`=${resolvedDevice}`] || process.cwd();
219219

220220
// Verify that a cwd was found and that it actually points
221221
// to our drive. If not, default to the drive's root.

src/vs/base/common/platform.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const LANGUAGE_DEFAULT = 'en';
88
let _isWindows = false;
99
let _isMacintosh = false;
1010
let _isLinux = false;
11+
let _isLinuxSnap = false;
1112
let _isNative = false;
1213
let _isWeb = false;
1314
let _isIOS = false;
@@ -79,6 +80,7 @@ else if (typeof nodeProcess === 'object') {
7980
_isWindows = (nodeProcess.platform === 'win32');
8081
_isMacintosh = (nodeProcess.platform === 'darwin');
8182
_isLinux = (nodeProcess.platform === 'linux');
83+
_isLinuxSnap = _isLinux && !!nodeProcess.env['SNAP'] && !!nodeProcess.env['SNAP_REVISION'];
8284
_locale = LANGUAGE_DEFAULT;
8385
_language = LANGUAGE_DEFAULT;
8486
const rawNlsConfig = nodeProcess.env['VSCODE_NLS_CONFIG'];
@@ -128,6 +130,7 @@ if (_isMacintosh) {
128130
export const isWindows = _isWindows;
129131
export const isMacintosh = _isMacintosh;
130132
export const isLinux = _isLinux;
133+
export const isLinuxSnap = _isLinuxSnap;
131134
export const isNative = _isNative;
132135
export const isWeb = _isWeb;
133136
export const isIOS = _isIOS;

src/vs/base/node/processes.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function terminateProcess(process: cp.ChildProcess, cwd?: string): Promise<Termi
5050
options.cwd = cwd;
5151
}
5252
const killProcess = cp.execFile('taskkill', ['/T', '/F', '/PID', process.pid.toString()], options);
53-
return new Promise((resolve, reject) => {
53+
return new Promise(resolve => {
5454
killProcess.once('error', (err) => {
5555
resolve({ success: false, error: err });
5656
});
@@ -68,7 +68,7 @@ function terminateProcess(process: cp.ChildProcess, cwd?: string): Promise<Termi
6868
} else if (Platform.isLinux || Platform.isMacintosh) {
6969
try {
7070
const cmd = FileAccess.asFileUri('vs/base/node/terminateProcess.sh', require).fsPath;
71-
return new Promise((resolve, reject) => {
71+
return new Promise(resolve => {
7272
cp.execFile(cmd, [process.pid.toString()], { encoding: 'utf8', shell: true } as cp.ExecFileOptions, (err, stdout, stderr) => {
7373
if (err) {
7474
resolve({ success: false, error: err });
@@ -86,8 +86,8 @@ function terminateProcess(process: cp.ChildProcess, cwd?: string): Promise<Termi
8686
return Promise.resolve({ success: true });
8787
}
8888

89-
export function getWindowsShell(environment: Platform.IProcessEnvironment = process.env as Platform.IProcessEnvironment): string {
90-
return environment['comspec'] || 'cmd.exe';
89+
export function getWindowsShell(env = process.env as Platform.IProcessEnvironment): string {
90+
return env['comspec'] || 'cmd.exe';
9191
}
9292

9393
export abstract class AbstractProcess<TProgressData> {
@@ -447,8 +447,8 @@ export namespace win32 {
447447
// to the current working directory.
448448
return path.join(cwd, command);
449449
}
450-
if (paths === undefined && Types.isString(process.env.PATH)) {
451-
paths = process.env.PATH.split(path.delimiter);
450+
if (paths === undefined && Types.isString(process.env['PATH'])) {
451+
paths = process.env['PATH'].split(path.delimiter);
452452
}
453453
// No PATH environment. Make path absolute to the cwd.
454454
if (paths === undefined || paths.length === 0) {

src/vs/base/node/shell.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,29 @@ import * as processes from 'vs/base/node/processes';
1212
* shell that the terminal uses by default.
1313
* @param p The platform to detect the shell of.
1414
*/
15-
export function getSystemShell(p: platform.Platform, environment: platform.IProcessEnvironment = process.env as platform.IProcessEnvironment): string {
15+
export function getSystemShell(p: platform.Platform, env = process.env as platform.IProcessEnvironment): string {
1616
if (p === platform.Platform.Windows) {
1717
if (platform.isWindows) {
18-
return getSystemShellWindows(environment);
18+
return getSystemShellWindows(env);
1919
}
2020
// Don't detect Windows shell when not on Windows
21-
return processes.getWindowsShell(environment);
21+
return processes.getWindowsShell(env);
2222
}
2323
// Only use $SHELL for the current OS
2424
if (platform.isLinux && p === platform.Platform.Mac || platform.isMacintosh && p === platform.Platform.Linux) {
2525
return '/bin/bash';
2626
}
27-
return getSystemShellUnixLike(environment);
27+
return getSystemShellUnixLike(env);
2828
}
2929

3030
let _TERMINAL_DEFAULT_SHELL_UNIX_LIKE: string | null = null;
31-
function getSystemShellUnixLike(environment: platform.IProcessEnvironment): string {
31+
function getSystemShellUnixLike(env: platform.IProcessEnvironment): string {
3232
if (!_TERMINAL_DEFAULT_SHELL_UNIX_LIKE) {
3333
let unixLikeTerminal: string;
3434
if (platform.isWindows) {
3535
unixLikeTerminal = '/bin/bash'; // for WSL
3636
} else {
37-
unixLikeTerminal = environment.SHELL;
37+
unixLikeTerminal = env['SHELL'];
3838

3939
if (!unixLikeTerminal) {
4040
try {
@@ -59,12 +59,12 @@ function getSystemShellUnixLike(environment: platform.IProcessEnvironment): stri
5959
}
6060

6161
let _TERMINAL_DEFAULT_SHELL_WINDOWS: string | null = null;
62-
function getSystemShellWindows(environment: platform.IProcessEnvironment): string {
62+
function getSystemShellWindows(env: platform.IProcessEnvironment): string {
6363
if (!_TERMINAL_DEFAULT_SHELL_WINDOWS) {
6464
const isAtLeastWindows10 = platform.isWindows && parseFloat(os.release()) >= 10;
65-
const is32ProcessOn64Windows = environment.hasOwnProperty('PROCESSOR_ARCHITEW6432');
66-
const powerShellPath = `${environment.windir}\\${is32ProcessOn64Windows ? 'Sysnative' : 'System32'}\\WindowsPowerShell\\v1.0\\powershell.exe`;
67-
_TERMINAL_DEFAULT_SHELL_WINDOWS = isAtLeastWindows10 ? powerShellPath : processes.getWindowsShell(environment);
65+
const is32ProcessOn64Windows = env.hasOwnProperty('PROCESSOR_ARCHITEW6432');
66+
const powerShellPath = `${env['windir']}\\${is32ProcessOn64Windows ? 'Sysnative' : 'System32'}\\WindowsPowerShell\\v1.0\\powershell.exe`;
67+
_TERMINAL_DEFAULT_SHELL_WINDOWS = isAtLeastWindows10 ? powerShellPath : processes.getWindowsShell(env);
6868
}
6969
return _TERMINAL_DEFAULT_SHELL_WINDOWS;
7070
}

src/vs/base/parts/ipc/test/node/ipc.cp.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { getPathFromAmdModule } from 'vs/base/common/amd';
1111
function createClient(): Client {
1212
return new Client(getPathFromAmdModule(require, 'bootstrap-fork'), {
1313
serverName: 'TestServer',
14-
env: { AMD_ENTRYPOINT: 'vs/base/parts/ipc/test/node/testApp', verbose: true }
14+
env: { VSCODE_AMD_ENTRYPOINT: 'vs/base/parts/ipc/test/node/testApp', verbose: true }
1515
});
1616
}
1717

src/vs/base/test/node/processes/processes.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ import { getPathFromAmdModule } from 'vs/base/common/amd';
1313
function fork(id: string): cp.ChildProcess {
1414
const opts: any = {
1515
env: objects.mixin(objects.deepClone(process.env), {
16-
AMD_ENTRYPOINT: id,
17-
PIPE_LOGGING: 'true',
18-
VERBOSE_LOGGING: true
16+
VSCODE_AMD_ENTRYPOINT: id,
17+
VSCODE_PIPE_LOGGING: 'true',
18+
VSCODE_VERBOSE_LOGGING: true
1919
})
2020
};
2121

src/vs/code/electron-main/app.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import { app, ipcMain, systemPreferences, contentTracing, protocol, BrowserWindow, dialog, session } from 'electron';
7-
import { IProcessEnvironment, isWindows, isMacintosh, isLinux } from 'vs/base/common/platform';
7+
import { IProcessEnvironment, isWindows, isMacintosh, isLinux, isLinuxSnap } from 'vs/base/common/platform';
88
import { WindowsMainService } from 'vs/platform/windows/electron-main/windowsMainService';
99
import { IWindowOpenable } from 'vs/platform/windows/common/windows';
1010
import { ILifecycleMainService, LifecycleMainPhase } from 'vs/platform/lifecycle/electron-main/lifecycleMainService';
@@ -294,7 +294,7 @@ export class CodeApplication extends Disposable {
294294
// - an error after 10s and stop trying to resolve
295295
const cts = new CancellationTokenSource();
296296
const shellEnvSlowWarningHandle = setTimeout(() => window?.sendWhenReady('vscode:showShellEnvSlowWarning', cts.token), 3000);
297-
const shellEnvTimeoutErrorHandle = setTimeout(function () {
297+
const shellEnvTimeoutErrorHandle = setTimeout(() => {
298298
cts.dispose(true);
299299
window?.sendWhenReady('vscode:showShellEnvTimeoutError', CancellationToken.None);
300300
acceptShellEnv({});
@@ -491,8 +491,8 @@ export class CodeApplication extends Disposable {
491491
break;
492492

493493
case 'linux':
494-
if (process.env.SNAP && process.env.SNAP_REVISION) {
495-
services.set(IUpdateService, new SyncDescriptor(SnapUpdateService, [process.env.SNAP, process.env.SNAP_REVISION]));
494+
if (isLinuxSnap) {
495+
services.set(IUpdateService, new SyncDescriptor(SnapUpdateService, [process.env['SNAP'], process.env['SNAP_REVISION']]));
496496
} else {
497497
services.set(IUpdateService, new SyncDescriptor(LinuxUpdateService));
498498
}

src/vs/code/electron-main/window.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -643,32 +643,32 @@ export class CodeWindow extends Disposable implements ICodeWindow {
643643
}
644644

645645
private onConfigurationUpdated(): void {
646+
647+
// Menubar
646648
const newMenuBarVisibility = this.getMenuBarVisibility();
647649
if (newMenuBarVisibility !== this.currentMenuBarVisibility) {
648650
this.currentMenuBarVisibility = newMenuBarVisibility;
649651
this.setMenuBarVisibility(newMenuBarVisibility);
650652
}
651653

652-
// Do not set to empty configuration at startup if setting is empty to not override configuration through CLI options:
653-
const env = process.env;
654+
// Proxy
654655
let newHttpProxy = (this.configurationService.getValue<string>('http.proxy') || '').trim()
655-
|| (env.https_proxy || process.env.HTTPS_PROXY || process.env.http_proxy || process.env.HTTP_PROXY || '').trim() // Not standardized.
656+
|| (process.env['https_proxy'] || process.env['HTTPS_PROXY'] || process.env['http_proxy'] || process.env['HTTP_PROXY'] || '').trim() // Not standardized.
656657
|| undefined;
658+
657659
if (newHttpProxy?.endsWith('/')) {
658660
newHttpProxy = newHttpProxy.substr(0, newHttpProxy.length - 1);
659661
}
660-
const newNoProxy = (env.no_proxy || env.NO_PROXY || '').trim() || undefined; // Not standardized.
662+
663+
const newNoProxy = (process.env['no_proxy'] || process.env['NO_PROXY'] || '').trim() || undefined; // Not standardized.
661664
if ((newHttpProxy || '').indexOf('@') === -1 && (newHttpProxy !== this.currentHttpProxy || newNoProxy !== this.currentNoProxy)) {
662665
this.currentHttpProxy = newHttpProxy;
663666
this.currentNoProxy = newNoProxy;
667+
664668
const proxyRules = newHttpProxy || '';
665669
const proxyBypassRules = newNoProxy ? `${newNoProxy},<local>` : '<local>';
666670
this.logService.trace(`Setting proxy to '${proxyRules}', bypassing '${proxyBypassRules}'`);
667-
this._win.webContents.session.setProxy({
668-
proxyRules,
669-
proxyBypassRules,
670-
pacScript: '',
671-
});
671+
this._win.webContents.session.setProxy({ proxyRules, proxyBypassRules, pacScript: '' });
672672
}
673673
}
674674

src/vs/code/electron-sandbox/issue/issueReporterMain.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import 'vs/css!./media/issueReporter';
77
import 'vs/base/browser/ui/codicons/codiconStyles'; // make sure codicon css is loaded
88
import { INativeHostService } from 'vs/platform/native/electron-sandbox/native';
99
import { NativeHostService } from 'vs/platform/native/electron-sandbox/nativeHostService';
10-
import { ipcRenderer, process } from 'vs/base/parts/sandbox/electron-sandbox/globals';
10+
import { ipcRenderer } from 'vs/base/parts/sandbox/electron-sandbox/globals';
1111
import { applyZoom, zoomIn, zoomOut } from 'vs/platform/windows/electron-sandbox/window';
1212
import { $, reset, safeInnerHtml, windowOpenNoOpener } from 'vs/base/browser/dom';
1313
import { Button } from 'vs/base/browser/ui/button/button';
@@ -83,14 +83,12 @@ export class IssueReporter extends Disposable {
8383

8484
this.initServices(configuration);
8585

86-
const isSnap = process.platform === 'linux' && process.env.SNAP && process.env.SNAP_REVISION;
87-
8886
const targetExtension = configuration.data.extensionId ? configuration.data.enabledExtensions.find(extension => extension.id === configuration.data.extensionId) : undefined;
8987
this.issueReporterModel = new IssueReporterModel({
9088
issueType: configuration.data.issueType || IssueType.Bug,
9189
versionInfo: {
9290
vscodeVersion: `${configuration.product.nameShort} ${configuration.product.version} (${configuration.product.commit || 'Commit unknown'}, ${configuration.product.date || 'Date unknown'})`,
93-
os: `${this.configuration.os.type} ${this.configuration.os.arch} ${this.configuration.os.release}${isSnap ? ' snap' : ''}`
91+
os: `${this.configuration.os.type} ${this.configuration.os.arch} ${this.configuration.os.release}${platform.isLinuxSnap ? ' snap' : ''}`
9492
},
9593
extensionsDisabled: !!configuration.disableExtensions,
9694
fileOnExtension: configuration.data.extensionId ? !targetExtension?.isBuiltin : undefined,

0 commit comments

Comments
 (0)