提交 0a81c69e 编写于 作者: J Joao Moreno

dont assign process.env when spawned from cli

fixes #1033
上级 a05cb186
......@@ -5,7 +5,6 @@
'use strict';
import platform = require('vs/base/common/platform');
import { TPromise } from 'vs/base/common/winjs.base';
import cp = require('child_process');
......@@ -13,11 +12,7 @@ export interface IEnv {
[key: string]: string;
}
export function getUserEnvironment(): TPromise<IEnv> {
if (platform.isWindows) {
return TPromise.as({});
}
export function getUnixUserEnvironment(): TPromise<IEnv> {
return new TPromise((c, e) => {
let child = cp.spawn(process.env.SHELL, ['-ilc', 'env'], {
detached: true,
......
......@@ -49,7 +49,10 @@ export interface IMainEnvironment extends IEnvironment {
export function startup(environment: IMainEnvironment, globalSettings: IGlobalSettings): winjs.TPromise<void> {
// Inherit the user environment
assign(process.env, environment.userEnv);
// TODO@Joao: this inheritance should **not** happen here!
if (process.env['VSCODE_CLI'] !== '1') {
assign(process.env, environment.userEnv);
}
// Shell Configuration
let shellConfiguration: IConfiguration = {
......
......@@ -16,7 +16,10 @@ export function main(args: string[]) {
} else if (argv.version) {
console.log(pkg.version);
} else {
const env = assign({}, process.env);
const env = assign({}, process.env, {
// this will signal Code that it was spawned from this module
'VSCODE_CLI': '1'
});
delete env['ATOM_SHELL_INTERNAL_RUN_AS_NODE'];
const child = spawn(process.execPath, args, {
......
......@@ -17,7 +17,7 @@ import { VSCodeMenu } from 'vs/workbench/electron-main/menus';
import {ISettingsService, SettingsManager} from 'vs/workbench/electron-main/settings';
import {IUpdateService, UpdateManager} from 'vs/workbench/electron-main/update-manager';
import {Server, serve, connect} from 'vs/base/parts/ipc/node/ipc.net';
import {getUserEnvironment} from 'vs/base/node/env';
import {getUnixUserEnvironment, IEnv} from 'vs/base/node/env';
import {TPromise} from 'vs/base/common/winjs.base';
import {AskpassChannel} from 'vs/workbench/parts/git/common/gitIpc';
import {GitAskpassService} from 'vs/workbench/parts/git/electron-main/askpassService';
......@@ -266,11 +266,18 @@ services.set(ISettingsService, new SyncDescriptor(SettingsManager));
const instantiationService = new InstantiationService(services);
function getUserEnvironment(): TPromise<IEnv> {
return platform.isWindows ? TPromise.as({}) : getUnixUserEnvironment();
}
// On some platforms we need to manually read from the global environment variables
// and assign them to the process environment (e.g. when doubleclick app on Mac)
getUserEnvironment()
.then(userEnv => {
assign(process.env, userEnv);
if (process.env['VSCODE_CLI'] !== '1') {
assign(process.env, userEnv);
}
// Make sure the NLS Config travels to the rendered process
// See also https://github.com/Microsoft/vscode/issues/4558
userEnv['VSCODE_NLS_CONFIG'] = process.env['VSCODE_NLS_CONFIG'];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册