Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
35ef7bc1
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
35ef7bc1
编写于
8月 05, 2016
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
clean up env passing from main to renderers
related to #10194
上级
b4e188f9
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
58 addition
and
33 deletion
+58
-33
src/vs/code/electron-main/main.ts
src/vs/code/electron-main/main.ts
+46
-21
src/vs/code/electron-main/windows.ts
src/vs/code/electron-main/windows.ts
+9
-5
src/vs/workbench/electron-browser/index.html
src/vs/workbench/electron-browser/index.html
+2
-2
src/vs/workbench/electron-browser/main.ts
src/vs/workbench/electron-browser/main.ts
+1
-5
未找到文件。
src/vs/code/electron-main/main.ts
浏览文件 @
35ef7bc1
...
...
@@ -102,11 +102,6 @@ function main(accessor: ServicesAccessor, ipcServer: Server, userEnv: IProcessEn
const
askpassChannel
=
new
AskpassChannel
(
askpassService
);
ipcServer
.
registerChannel
(
'
askpass
'
,
askpassChannel
);
// Used by sub processes to communicate back to the main instance
process
.
env
[
'
VSCODE_PID
'
]
=
''
+
process
.
pid
;
process
.
env
[
'
VSCODE_IPC_HOOK
'
]
=
envService
.
mainIPCHandle
;
process
.
env
[
'
VSCODE_SHARED_IPC_HOOK
'
]
=
envService
.
sharedIPCHandle
;
// Spawn shared process
const
sharedProcess
=
spawnSharedProcess
({
allowOutput
:
!
envService
.
isBuilt
||
envService
.
cliArgs
.
verboseLogging
,
...
...
@@ -332,24 +327,54 @@ function getUnixUserEnvironment(): TPromise<IEnv> {
return
promise
.
then
(
null
,
()
=>
({}));
}
/**
* On Unix systems, we might need to get the environment
* from a user's shell. This should only be done when Code
* is not launched from a Terminal.
*/
function
getUserShellEnvironment
():
TPromise
<
IEnv
>
{
if
(
platform
.
isWindows
)
{
return
TPromise
.
as
({});
}
if
(
process
.
env
[
'
VSCODE_CLI
'
]
===
'
1
'
)
{
return
TPromise
.
as
({});
}
return
getUnixUserEnvironment
();
}
/**
* Returns the user environment necessary for all Code processes.
* Such environment needs to be propagated to the renderer/shared
* processes.
*/
function
getUserEnvironment
():
TPromise
<
IEnv
>
{
return
platform
.
isWindows
?
TPromise
.
as
({})
:
getUnixUserEnvironment
();
return
getUserShellEnvironment
().
then
(
userShellEnv
=>
{
return
instantiationService
.
invokeFunction
(
a
=>
{
const
envService
=
a
.
get
(
IEnvironmentService
);
const
instanceEnv
=
{
VSCODE_PID
:
String
(
process
.
pid
),
VSCODE_IPC_HOOK
:
envService
.
mainIPCHandle
,
VSCODE_SHARED_IPC_HOOK
:
envService
.
sharedIPCHandle
};
return
assign
({},
userShellEnv
,
instanceEnv
);
});
});
}
// 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
=>
{
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
'
];
return
instantiationService
.
invokeFunction
(
a
=>
a
.
get
(
IEnvironmentService
).
createPaths
())
.
then
(()
=>
instantiationService
.
invokeFunction
(
setupIPC
))
.
then
(
ipcServer
=>
instantiationService
.
invokeFunction
(
main
,
ipcServer
,
userEnv
));
})
.
done
(
null
,
err
=>
instantiationService
.
invokeFunction
(
quit
,
err
));
\ No newline at end of file
getUserEnvironment
().
then
(
userEnv
=>
{
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
'
];
return
instantiationService
.
invokeFunction
(
a
=>
a
.
get
(
IEnvironmentService
).
createPaths
())
.
then
(()
=>
instantiationService
.
invokeFunction
(
setupIPC
))
.
then
(
ipcServer
=>
instantiationService
.
invokeFunction
(
main
,
ipcServer
,
userEnv
));
})
.
done
(
null
,
err
=>
instantiationService
.
invokeFunction
(
quit
,
err
));
\ No newline at end of file
src/vs/code/electron-main/windows.ts
浏览文件 @
35ef7bc1
...
...
@@ -11,7 +11,7 @@ import * as platform from 'vs/base/common/platform';
import
*
as
nls
from
'
vs/nls
'
;
import
*
as
paths
from
'
vs/base/common/paths
'
;
import
*
as
arrays
from
'
vs/base/common/arrays
'
;
import
*
as
objects
from
'
vs/base/common/objects
'
;
import
{
assign
,
mixin
}
from
'
vs/base/common/objects
'
;
import
pkg
from
'
vs/platform/package
'
;
import
{
EventEmitter
}
from
'
events
'
;
import
{
IStorageService
}
from
'
vs/code/electron-main/storage
'
;
...
...
@@ -604,7 +604,7 @@ export class WindowsManager implements IWindowsService {
// Otherwise open instance with files
else
{
configuration
=
this
.
toConfiguration
(
openConfig
.
userEnv
||
this
.
initialUserEnv
,
openConfig
.
cli
,
null
,
filesToOpen
,
filesToCreate
,
filesToDiff
,
extensionsToInstall
);
configuration
=
this
.
toConfiguration
(
this
.
getWindowUserEnv
(
openConfig
)
,
openConfig
.
cli
,
null
,
filesToOpen
,
filesToCreate
,
filesToDiff
,
extensionsToInstall
);
let
browserWindow
=
this
.
openInBrowserWindow
(
configuration
,
true
/* new window */
);
usedWindows
.
push
(
browserWindow
);
...
...
@@ -650,7 +650,7 @@ export class WindowsManager implements IWindowsService {
return
;
// ignore folders that are already open
}
configuration
=
this
.
toConfiguration
(
openConfig
.
userEnv
||
this
.
initialUserEnv
,
openConfig
.
cli
,
folderToOpen
.
workspacePath
,
filesToOpen
,
filesToCreate
,
filesToDiff
,
extensionsToInstall
);
configuration
=
this
.
toConfiguration
(
this
.
getWindowUserEnv
(
openConfig
)
,
openConfig
.
cli
,
folderToOpen
.
workspacePath
,
filesToOpen
,
filesToCreate
,
filesToDiff
,
extensionsToInstall
);
let
browserWindow
=
this
.
openInBrowserWindow
(
configuration
,
openInNewWindow
,
openInNewWindow
?
void
0
:
openConfig
.
windowToUse
);
usedWindows
.
push
(
browserWindow
);
...
...
@@ -667,7 +667,7 @@ export class WindowsManager implements IWindowsService {
// Handle empty
if
(
emptyToOpen
.
length
>
0
)
{
emptyToOpen
.
forEach
(()
=>
{
let
configuration
=
this
.
toConfiguration
(
openConfig
.
userEnv
||
this
.
initialUserEnv
,
openConfig
.
cli
);
let
configuration
=
this
.
toConfiguration
(
this
.
getWindowUserEnv
(
openConfig
)
,
openConfig
.
cli
);
let
browserWindow
=
this
.
openInBrowserWindow
(
configuration
,
openInNewWindow
,
openInNewWindow
?
void
0
:
openConfig
.
windowToUse
);
usedWindows
.
push
(
browserWindow
);
...
...
@@ -688,6 +688,10 @@ export class WindowsManager implements IWindowsService {
return
arrays
.
distinct
(
usedWindows
);
}
private
getWindowUserEnv
(
openConfig
:
IOpenConfiguration
):
IProcessEnvironment
{
return
assign
({},
this
.
initialUserEnv
,
openConfig
.
userEnv
||
{});
}
public
openPluginDevelopmentHostWindow
(
openConfig
:
IOpenConfiguration
):
void
{
// Reload an existing plugin development host window on the same path
...
...
@@ -722,7 +726,7 @@ export class WindowsManager implements IWindowsService {
}
private
toConfiguration
(
userEnv
:
IProcessEnvironment
,
cli
:
ICommandLineArguments
,
workspacePath
?:
string
,
filesToOpen
?:
IPath
[],
filesToCreate
?:
IPath
[],
filesToDiff
?:
IPath
[],
extensionsToInstall
?:
string
[]):
IWindowConfiguration
{
let
configuration
:
IWindowConfiguration
=
objects
.
mixin
({},
cli
);
// inherit all properties from CLI
let
configuration
:
IWindowConfiguration
=
mixin
({},
cli
);
// inherit all properties from CLI
configuration
.
execPath
=
process
.
execPath
;
configuration
.
workspacePath
=
workspacePath
;
configuration
.
filesToOpen
=
filesToOpen
;
...
...
src/vs/workbench/electron-browser/index.html
浏览文件 @
35ef7bc1
...
...
@@ -111,8 +111,8 @@
var
enableDeveloperTools
=
!
configuration
.
isBuilt
||
!!
configuration
.
extensionDevelopmentPath
;
// Linux is a PAIN https://github.com/electron/electron/issues/3306
process
.
env
[
'
VSCODE_IPC_HOOK
'
]
=
configuration
.
mainIPCHandle
;
process
.
env
[
'
VSCODE_SHARED_IPC_HOOK
'
]
=
configuration
.
sharedIPCHandle
;
//
process.env['VSCODE_IPC_HOOK'] = configuration.mainIPCHandle;
//
process.env['VSCODE_SHARED_IPC_HOOK'] = configuration.sharedIPCHandle;
// Get the nls configuration into the process.env as early as possible.
var
nlsConfig
=
{
availableLanguages
:
{}
};
...
...
src/vs/workbench/electron-browser/main.ts
浏览文件 @
35ef7bc1
...
...
@@ -56,12 +56,8 @@ export interface IMainEnvironment extends IEnvironment {
}
export
function
startup
(
environment
:
IMainEnvironment
,
globalSettings
:
IGlobalSettings
):
winjs
.
TPromise
<
void
>
{
// Inherit the user environment
// TODO@Joao: this inheritance should **not** happen here!
if
(
process
.
env
[
'
VSCODE_CLI
'
]
!==
'
1
'
)
{
assign
(
process
.
env
,
environment
.
userEnv
);
}
assign
(
process
.
env
,
environment
.
userEnv
);
// Shell Configuration
let
shellConfiguration
:
IConfiguration
=
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录