Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
eb7161d2
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
eb7161d2
编写于
8月 19, 2016
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
move ipc handles to environment service
上级
3fc422cd
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
56 addition
and
56 deletion
+56
-56
src/vs/code/electron-main/env.ts
src/vs/code/electron-main/env.ts
+0
-49
src/vs/code/electron-main/main.ts
src/vs/code/electron-main/main.ts
+8
-6
src/vs/platform/environment/common/environment.ts
src/vs/platform/environment/common/environment.ts
+3
-0
src/vs/platform/environment/node/environmentService.ts
src/vs/platform/environment/node/environmentService.ts
+45
-1
未找到文件。
src/vs/code/electron-main/env.ts
浏览文件 @
eb7161d2
...
...
@@ -5,7 +5,6 @@
'
use strict
'
;
import
*
as
crypto
from
'
crypto
'
;
import
*
as
fs
from
'
original-fs
'
;
import
*
as
path
from
'
path
'
;
import
*
as
os
from
'
os
'
;
...
...
@@ -21,7 +20,6 @@ import * as types from 'vs/base/common/types';
import
{
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
product
,
{
IProductConfiguration
}
from
'
vs/platform/product
'
;
import
{
parseArgs
,
ParsedArgs
}
from
'
vs/code/node/argv
'
;
import
pkg
from
'
vs/platform/package
'
;
export
interface
IProcessEnvironment
{
[
key
:
string
]:
string
;
...
...
@@ -49,8 +47,6 @@ export interface IEnvService {
appSettingsHome
:
string
;
appSettingsPath
:
string
;
appKeybindingsPath
:
string
;
mainIPCHandle
:
string
;
sharedIPCHandle
:
string
;
createPaths
():
TPromise
<
void
>
;
}
...
...
@@ -95,12 +91,6 @@ export class EnvService implements IEnvService {
private
_appKeybindingsPath
:
string
;
get
appKeybindingsPath
():
string
{
return
this
.
_appKeybindingsPath
;
}
private
_mainIPCHandle
:
string
;
get
mainIPCHandle
():
string
{
return
this
.
_mainIPCHandle
;
}
private
_sharedIPCHandle
:
string
;
get
sharedIPCHandle
():
string
{
return
this
.
_sharedIPCHandle
;
}
constructor
()
{
this
.
_appRoot
=
path
.
dirname
(
URI
.
parse
(
require
.
toUrl
(
''
)).
fsPath
);
this
.
_currentWorkingDirectory
=
process
.
env
[
'
VSCODE_CWD
'
]
||
process
.
cwd
();
...
...
@@ -147,45 +137,6 @@ export class EnvService implements IEnvService {
this
.
_isTestingFromCli
=
this
.
cliArgs
.
extensionTestsPath
&&
!
this
.
cliArgs
.
debugBrkPluginHost
;
this
.
_userHome
=
path
.
join
(
os
.
homedir
(),
product
.
dataFolderName
);
this
.
_userExtensionsHome
=
this
.
cliArgs
.
extensionHomePath
||
path
.
join
(
this
.
_userHome
,
'
extensions
'
);
const
prefix
=
this
.
getIPCHandleBaseName
();
const
suffix
=
process
.
platform
===
'
win32
'
?
'
-sock
'
:
'
.sock
'
;
this
.
_mainIPCHandle
=
`
${
prefix
}
-
${
pkg
.
version
}${
suffix
}
`
;
this
.
_sharedIPCHandle
=
`
${
prefix
}
-
${
pkg
.
version
}
-shared
${
suffix
}
`
;
}
private
getIPCHandleBaseName
():
string
{
let
name
=
pkg
.
name
;
// Support to run VS Code multiple times as different user
// by making the socket unique over the logged in user
let
userId
=
EnvService
.
getUniqueUserId
();
if
(
userId
)
{
name
+=
`-
${
userId
}
`
;
}
if
(
process
.
platform
===
'
win32
'
)
{
return
`\\\\.\\pipe\
\$
{ name }`
;
}
return
path
.
join
(
os
.
tmpdir
(),
name
);
}
private
static
getUniqueUserId
():
string
{
let
username
:
string
;
if
(
platform
.
isWindows
)
{
username
=
process
.
env
.
USERNAME
;
}
else
{
username
=
process
.
env
.
USER
;
}
if
(
!
username
)
{
return
''
;
// fail gracefully if there is no user name
}
// use sha256 to ensure the userid value can be used in filenames and are unique
return
crypto
.
createHash
(
'
sha256
'
).
update
(
username
).
digest
(
'
hex
'
).
substr
(
0
,
6
);
}
createPaths
():
TPromise
<
void
>
{
...
...
src/vs/code/electron-main/main.ts
浏览文件 @
eb7161d2
...
...
@@ -203,10 +203,11 @@ function main(accessor: ServicesAccessor, mainIpcServer: Server, userEnv: IProce
function
setupIPC
(
accessor
:
ServicesAccessor
):
TPromise
<
Server
>
{
const
logService
=
accessor
.
get
(
ILogService
);
const
environmentService
=
accessor
.
get
(
IEnvironmentService
);
const
envService
=
accessor
.
get
(
IEnvService
);
function
setup
(
retry
:
boolean
):
TPromise
<
Server
>
{
return
serve
(
envService
.
mainIPCHandle
).
then
(
server
=>
{
return
serve
(
env
ironment
Service
.
mainIPCHandle
).
then
(
server
=>
{
if
(
platform
.
isMacintosh
)
{
app
.
dock
.
show
();
// dock might be hidden at this case due to a retry
}
...
...
@@ -223,7 +224,7 @@ function setupIPC(accessor: ServicesAccessor): TPromise<Server> {
}
// there's a running instance, let's connect to it
return
connect
(
envService
.
mainIPCHandle
).
then
(
return
connect
(
env
ironment
Service
.
mainIPCHandle
).
then
(
client
=>
{
// Tests from CLI require to be the only instance currently (TODO@Ben support multiple instances and output)
...
...
@@ -252,7 +253,7 @@ function setupIPC(accessor: ServicesAccessor): TPromise<Server> {
// let's delete it, since we can't connect to it
// and the retry the whole thing
try
{
fs
.
unlinkSync
(
envService
.
mainIPCHandle
);
fs
.
unlinkSync
(
env
ironment
Service
.
mainIPCHandle
);
}
catch
(
e
)
{
logService
.
log
(
'
Fatal error deleting obsolete instance handle
'
,
e
);
return
TPromise
.
wrapError
(
e
);
...
...
@@ -370,11 +371,12 @@ function getShellEnvironment(): TPromise<IEnv> {
function
getEnvironment
():
TPromise
<
IEnv
>
{
return
getShellEnvironment
().
then
(
shellEnv
=>
{
return
instantiationService
.
invokeFunction
(
a
=>
{
const
envService
=
a
.
get
(
IEnvService
);
const
environmentService
=
a
.
get
(
IEnvironmentService
);
const
instanceEnv
=
{
VSCODE_PID
:
String
(
process
.
pid
),
VSCODE_IPC_HOOK
:
envService
.
mainIPCHandle
,
VSCODE_SHARED_IPC_HOOK
:
envService
.
sharedIPCHandle
,
VSCODE_IPC_HOOK
:
env
ironment
Service
.
mainIPCHandle
,
VSCODE_SHARED_IPC_HOOK
:
env
ironment
Service
.
sharedIPCHandle
,
VSCODE_NLS_CONFIG
:
process
.
env
[
'
VSCODE_NLS_CONFIG
'
]
};
...
...
src/vs/platform/environment/common/environment.ts
浏览文件 @
eb7161d2
...
...
@@ -32,4 +32,7 @@ export interface IEnvironmentService {
isBuilt
:
boolean
;
verbose
:
boolean
;
performance
:
boolean
;
mainIPCHandle
:
string
;
sharedIPCHandle
:
string
;
}
\ No newline at end of file
src/vs/platform/environment/node/environmentService.ts
浏览文件 @
eb7161d2
...
...
@@ -4,13 +4,15 @@
*--------------------------------------------------------------------------------------------*/
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
*
as
crypto
from
'
crypto
'
;
import
*
as
paths
from
'
vs/base/node/paths
'
;
import
product
from
'
vs/platform/product
'
;
import
*
as
os
from
'
os
'
;
import
*
as
path
from
'
path
'
;
import
{
ParsedArgs
}
from
'
vs/code/node/argv
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
memoize
}
from
'
vs/base/common/decorators
'
;
import
pkg
from
'
vs/platform/package
'
;
import
product
from
'
vs/platform/product
'
;
// TODO@Ben TODO@Joao this interface should be composed once the main => renderer
// communication is also fit for that
...
...
@@ -18,6 +20,42 @@ export interface IEnvironment extends ParsedArgs {
execPath
:
string
;
}
function
getUniqueUserId
():
string
{
let
username
:
string
;
if
(
process
.
platform
===
'
win32
'
)
{
username
=
process
.
env
.
USERNAME
;
}
else
{
username
=
process
.
env
.
USER
;
}
if
(
!
username
)
{
return
''
;
// fail gracefully if there is no user name
}
// use sha256 to ensure the userid value can be used in filenames and are unique
return
crypto
.
createHash
(
'
sha256
'
).
update
(
username
).
digest
(
'
hex
'
).
substr
(
0
,
6
);
}
function
getIPCHandleBaseName
():
string
{
let
name
=
pkg
.
name
;
// Support to run VS Code multiple times as different user
// by making the socket unique over the logged in user
let
userId
=
getUniqueUserId
();
if
(
userId
)
{
name
+=
`-
${
userId
}
`
;
}
if
(
process
.
platform
===
'
win32
'
)
{
return
`\\\\.\\pipe\
\$
{ name }`
;
}
return
path
.
join
(
os
.
tmpdir
(),
name
);
}
const
IPCHandlePrefix
=
getIPCHandleBaseName
();
const
IPCHandleSuffix
=
process
.
platform
===
'
win32
'
?
'
-sock
'
:
'
.sock
'
;
export
class
EnvironmentService
implements
IEnvironmentService
{
_serviceBrand
:
any
;
...
...
@@ -57,6 +95,12 @@ export class EnvironmentService implements IEnvironmentService {
get
performance
():
boolean
{
return
this
.
args
.
performance
;
}
get
logExtensionHostCommunication
():
boolean
{
return
this
.
args
.
logExtensionHostCommunication
;
}
@
memoize
get
mainIPCHandle
():
string
{
return
`
${
IPCHandlePrefix
}
-
${
pkg
.
version
}${
IPCHandleSuffix
}
`
;
}
@
memoize
get
sharedIPCHandle
():
string
{
return
`
${
IPCHandlePrefix
}
-
${
pkg
.
version
}
-shared
${
IPCHandleSuffix
}
`
;
}
constructor
(
private
args
:
IEnvironment
)
{}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录