Revert "Merge from vscode ada4bddb8edc69eea6ebaaa0e88c5f903cbd43d8 (#5529)" (#5553)

This reverts commit 5d44b6a6a7.
This commit is contained in:
Anthony Dresser
2019-05-20 17:07:32 -07:00
committed by GitHub
parent 1315b8e42a
commit c9a4f8f664
325 changed files with 3332 additions and 4501 deletions

View File

@@ -7,16 +7,11 @@ import * as cp from 'child_process';
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';
function getUnixShellEnvironment(logService: ILogService): Promise<typeof process.env> {
function getUnixShellEnvironment(): Promise<typeof process.env> {
const promise = new Promise<typeof process.env>((resolve, reject) => {
const runAsNode = process.env['ELECTRON_RUN_AS_NODE'];
logService.trace('getUnixShellEnvironment#runAsNode', runAsNode);
const noAttach = process.env['ELECTRON_NO_ATTACH_CONSOLE'];
logService.trace('getUnixShellEnvironment#noAttach', noAttach);
const mark = generateUuid().replace(/-/g, '').substr(0, 12);
const regex = new RegExp(mark + '(.*)' + mark);
@@ -26,9 +21,6 @@ function getUnixShellEnvironment(logService: ILogService): Promise<typeof proces
});
const command = `'${process.execPath}' -p '"${mark}" + JSON.stringify(process.env) + "${mark}"'`;
logService.trace('getUnixShellEnvironment#env', env);
logService.trace('getUnixShellEnvironment#spawn', command);
const child = cp.spawn(process.env.SHELL!, ['-ilc', command], {
detached: true,
stdio: ['ignore', 'pipe', process.stderr],
@@ -45,8 +37,6 @@ function getUnixShellEnvironment(logService: ILogService): Promise<typeof proces
}
const raw = Buffer.concat(buffers).toString('utf8');
logService.trace('getUnixShellEnvironment#raw', raw);
const match = regex.exec(raw);
const rawStripped = match ? match[1] : '{}';
@@ -68,10 +58,8 @@ function getUnixShellEnvironment(logService: ILogService): Promise<typeof proces
// https://github.com/Microsoft/vscode/issues/22593#issuecomment-336050758
delete env['XDG_RUNTIME_DIR'];
logService.trace('getUnixShellEnvironment#result', env);
resolve(env);
} catch (err) {
logService.error('getUnixShellEnvironment#error', err);
reject(err);
}
});
@@ -89,17 +77,14 @@ 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(): Promise<typeof process.env> {
if (_shellEnv === undefined) {
if (isWindows) {
logService.trace('getShellEnvironment: runing on windows, skipping');
_shellEnv = Promise.resolve({});
} else if (process.env['VSCODE_CLI'] === '1') {
logService.trace('getShellEnvironment: runing on CLI, skipping');
_shellEnv = Promise.resolve({});
} else {
logService.trace('getShellEnvironment: running on Unix');
_shellEnv = getUnixShellEnvironment(logService);
_shellEnv = getUnixShellEnvironment();
}
}