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

dont assign process.env when spawned from cli

fixes #1033
上级 a05cb186
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
'use strict'; 'use strict';
import platform = require('vs/base/common/platform');
import { TPromise } from 'vs/base/common/winjs.base'; import { TPromise } from 'vs/base/common/winjs.base';
import cp = require('child_process'); import cp = require('child_process');
...@@ -13,11 +12,7 @@ export interface IEnv { ...@@ -13,11 +12,7 @@ export interface IEnv {
[key: string]: string; [key: string]: string;
} }
export function getUserEnvironment(): TPromise<IEnv> { export function getUnixUserEnvironment(): TPromise<IEnv> {
if (platform.isWindows) {
return TPromise.as({});
}
return new TPromise((c, e) => { return new TPromise((c, e) => {
let child = cp.spawn(process.env.SHELL, ['-ilc', 'env'], { let child = cp.spawn(process.env.SHELL, ['-ilc', 'env'], {
detached: true, detached: true,
......
...@@ -49,7 +49,10 @@ export interface IMainEnvironment extends IEnvironment { ...@@ -49,7 +49,10 @@ export interface IMainEnvironment extends IEnvironment {
export function startup(environment: IMainEnvironment, globalSettings: IGlobalSettings): winjs.TPromise<void> { export function startup(environment: IMainEnvironment, globalSettings: IGlobalSettings): winjs.TPromise<void> {
// Inherit the user environment // 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 // Shell Configuration
let shellConfiguration: IConfiguration = { let shellConfiguration: IConfiguration = {
......
...@@ -16,7 +16,10 @@ export function main(args: string[]) { ...@@ -16,7 +16,10 @@ export function main(args: string[]) {
} else if (argv.version) { } else if (argv.version) {
console.log(pkg.version); console.log(pkg.version);
} else { } 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']; delete env['ATOM_SHELL_INTERNAL_RUN_AS_NODE'];
const child = spawn(process.execPath, args, { const child = spawn(process.execPath, args, {
......
...@@ -17,7 +17,7 @@ import { VSCodeMenu } from 'vs/workbench/electron-main/menus'; ...@@ -17,7 +17,7 @@ import { VSCodeMenu } from 'vs/workbench/electron-main/menus';
import {ISettingsService, SettingsManager} from 'vs/workbench/electron-main/settings'; import {ISettingsService, SettingsManager} from 'vs/workbench/electron-main/settings';
import {IUpdateService, UpdateManager} from 'vs/workbench/electron-main/update-manager'; import {IUpdateService, UpdateManager} from 'vs/workbench/electron-main/update-manager';
import {Server, serve, connect} from 'vs/base/parts/ipc/node/ipc.net'; 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 {TPromise} from 'vs/base/common/winjs.base';
import {AskpassChannel} from 'vs/workbench/parts/git/common/gitIpc'; import {AskpassChannel} from 'vs/workbench/parts/git/common/gitIpc';
import {GitAskpassService} from 'vs/workbench/parts/git/electron-main/askpassService'; import {GitAskpassService} from 'vs/workbench/parts/git/electron-main/askpassService';
...@@ -266,11 +266,18 @@ services.set(ISettingsService, new SyncDescriptor(SettingsManager)); ...@@ -266,11 +266,18 @@ services.set(ISettingsService, new SyncDescriptor(SettingsManager));
const instantiationService = new InstantiationService(services); 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 // 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) // and assign them to the process environment (e.g. when doubleclick app on Mac)
getUserEnvironment() getUserEnvironment()
.then(userEnv => { .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 // Make sure the NLS Config travels to the rendered process
// See also https://github.com/Microsoft/vscode/issues/4558 // See also https://github.com/Microsoft/vscode/issues/4558
userEnv['VSCODE_NLS_CONFIG'] = process.env['VSCODE_NLS_CONFIG']; 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.
先完成此消息的编辑!
想要评论请 注册