Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
徽霖
Vscode
提交
05334aea
V
Vscode
项目概览
徽霖
/
Vscode
通知
9
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,发现更多精彩内容 >>
提交
05334aea
编写于
10月 06, 2016
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more use of IEnvironmentService (for #10656)
上级
beeb7f20
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
29 addition
and
71 deletion
+29
-71
src/vs/code/electron-main/env.ts
src/vs/code/electron-main/env.ts
+4
-49
src/vs/code/electron-main/lifecycle.ts
src/vs/code/electron-main/lifecycle.ts
+3
-3
src/vs/code/electron-main/log.ts
src/vs/code/electron-main/log.ts
+3
-5
src/vs/code/electron-main/main.ts
src/vs/code/electron-main/main.ts
+3
-3
src/vs/code/electron-main/storage.ts
src/vs/code/electron-main/storage.ts
+5
-5
src/vs/code/electron-main/window.ts
src/vs/code/electron-main/window.ts
+6
-5
src/vs/code/electron-main/windows.ts
src/vs/code/electron-main/windows.ts
+3
-1
src/vs/platform/environment/common/environment.ts
src/vs/platform/environment/common/environment.ts
+1
-0
src/vs/platform/environment/node/environmentService.ts
src/vs/platform/environment/node/environmentService.ts
+1
-0
未找到文件。
src/vs/code/electron-main/env.ts
浏览文件 @
05334aea
...
...
@@ -7,17 +7,13 @@
import
*
as
fs
from
'
original-fs
'
;
import
*
as
path
from
'
path
'
;
import
*
as
os
from
'
os
'
;
import
{
app
}
from
'
electron
'
;
import
*
as
arrays
from
'
vs/base/common/arrays
'
;
import
*
as
strings
from
'
vs/base/common/strings
'
;
import
*
as
paths
from
'
vs/base/common/paths
'
;
import
*
as
platform
from
'
vs/base/common/platform
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
*
as
types
from
'
vs/base/common/types
'
;
import
{
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
parseArgs
,
ParsedArgs
}
from
'
vs/platform/environment/node/argv
'
;
import
product
from
'
vs/platform/product
'
;
export
interface
IProcessEnvironment
{
[
key
:
string
]:
string
;
...
...
@@ -32,14 +28,6 @@ export const IEnvService = createDecorator<IEnvService>('mainEnvironmentService'
export
interface
IEnvService
{
_serviceBrand
:
any
;
cliArgs
:
ICommandLineArguments
;
isBuilt
:
boolean
;
userHome
:
string
;
appRoot
:
string
;
currentWorkingDirectory
:
string
;
appHome
:
string
;
appSettingsHome
:
string
;
appSettingsPath
:
string
;
appKeybindingsPath
:
string
;
}
export
class
EnvService
implements
IEnvService
{
...
...
@@ -49,45 +37,14 @@ export class EnvService implements IEnvService {
private
_cliArgs
:
ICommandLineArguments
;
get
cliArgs
():
ICommandLineArguments
{
return
this
.
_cliArgs
;
}
private
_userExtensionsHome
:
string
;
get
userExtensionsHome
():
string
{
return
this
.
_userExtensionsHome
;
}
get
isBuilt
():
boolean
{
return
!
process
.
env
[
'
VSCODE_DEV
'
];
}
private
_userHome
:
string
;
get
userHome
():
string
{
return
this
.
_userHome
;
}
private
_appRoot
:
string
;
get
appRoot
():
string
{
return
this
.
_appRoot
;
}
private
_currentWorkingDirectory
:
string
;
get
currentWorkingDirectory
():
string
{
return
this
.
_currentWorkingDirectory
;
}
private
_appHome
:
string
;
get
appHome
():
string
{
return
this
.
_appHome
;
}
private
_appSettingsHome
:
string
;
get
appSettingsHome
():
string
{
return
this
.
_appSettingsHome
;
}
private
_appSettingsPath
:
string
;
get
appSettingsPath
():
string
{
return
this
.
_appSettingsPath
;
}
private
_appKeybindingsPath
:
string
;
get
appKeybindingsPath
():
string
{
return
this
.
_appKeybindingsPath
;
}
constructor
()
{
this
.
_appRoot
=
path
.
dirname
(
URI
.
parse
(
require
.
toUrl
(
''
)).
fsPath
);
this
.
_currentWorkingDirectory
=
process
.
env
[
'
VSCODE_CWD
'
]
||
process
.
cwd
();
this
.
_appHome
=
app
.
getPath
(
'
userData
'
);
this
.
_appSettingsHome
=
path
.
join
(
this
.
_appHome
,
'
User
'
);
this
.
_appSettingsPath
=
path
.
join
(
this
.
_appSettingsHome
,
'
settings.json
'
);
this
.
_appKeybindingsPath
=
path
.
join
(
this
.
_appSettingsHome
,
'
keybindings.json
'
);
// Remove the Electron executable
const
[,
...
args
]
=
process
.
argv
;
// If dev, remove the first non-option argument: it's the app location
if
(
!
this
.
isBuilt
)
{
const
isBuilt
=
!
process
.
env
[
'
VSCODE_DEV
'
];
if
(
!
isBuilt
)
{
const
index
=
arrays
.
firstIndex
(
args
,
a
=>
!
/^-/
.
test
(
a
));
if
(
index
>
-
1
)
{
...
...
@@ -96,7 +53,8 @@ export class EnvService implements IEnvService {
}
const
argv
=
parseArgs
(
args
);
const
paths
=
parsePathArguments
(
this
.
_currentWorkingDirectory
,
argv
.
_
,
argv
.
goto
);
const
cwd
=
process
.
env
[
'
VSCODE_CWD
'
]
||
process
.
cwd
();
const
paths
=
parsePathArguments
(
cwd
,
argv
.
_
,
argv
.
goto
);
this
.
_cliArgs
=
Object
.
freeze
({
_
:
[],
...
...
@@ -118,9 +76,6 @@ export class EnvService implements IEnvService {
locale
:
argv
.
locale
,
wait
:
argv
.
wait
});
this
.
_userHome
=
path
.
join
(
os
.
homedir
(),
product
.
dataFolderName
);
this
.
_userExtensionsHome
=
this
.
cliArgs
.
extensionHomePath
||
path
.
join
(
this
.
_userHome
,
'
extensions
'
);
}
}
...
...
src/vs/code/electron-main/lifecycle.ts
浏览文件 @
05334aea
...
...
@@ -9,7 +9,7 @@ import { EventEmitter } from 'events';
import
{
ipcMain
as
ipc
,
app
}
from
'
electron
'
;
import
{
TPromise
,
TValueCallback
}
from
'
vs/base/common/winjs.base
'
;
import
{
ReadyState
,
VSCodeWindow
}
from
'
vs/code/electron-main/window
'
;
import
{
IEnv
Service
}
from
'
vs/code/electron-main/env
'
;
import
{
IEnv
ironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
ILogService
}
from
'
vs/code/electron-main/log
'
;
import
{
IStorageService
}
from
'
vs/code/electron-main/storage
'
;
...
...
@@ -50,7 +50,7 @@ export class LifecycleService implements ILifecycleService {
private
_wasUpdated
:
boolean
;
constructor
(
@
IEnv
Service
private
envService
:
IEnv
Service
,
@
IEnv
ironmentService
private
environmentService
:
IEnvironment
Service
,
@
ILogService
private
logService
:
ILogService
,
@
IStorageService
private
storageService
:
IStorageService
)
{
...
...
@@ -109,7 +109,7 @@ export class LifecycleService implements ILifecycleService {
// Windows/Linux: we quit when all windows have closed
// Mac: we only quit when quit was requested
// --wait: we quit when all windows are closed
if
(
this
.
quitRequested
||
process
.
platform
!==
'
darwin
'
||
this
.
env
Service
.
cliArgs
.
wait
)
{
if
(
this
.
quitRequested
||
process
.
platform
!==
'
darwin
'
||
this
.
env
ironmentService
.
wait
)
{
app
.
quit
();
}
});
...
...
src/vs/code/electron-main/log.ts
浏览文件 @
05334aea
...
...
@@ -6,7 +6,7 @@
'
use strict
'
;
import
{
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IEnv
Service
}
from
'
vs/code/electron-main/env
'
;
import
{
IEnv
ironmentService
}
from
'
vs/platform/environment/common/environment
'
;
export
const
ILogService
=
createDecorator
<
ILogService
>
(
'
logService
'
);
...
...
@@ -19,13 +19,11 @@ export class MainLogService implements ILogService {
_serviceBrand
:
any
;
constructor
(@
IEnv
Service
private
envService
:
IEnv
Service
)
{
constructor
(@
IEnv
ironmentService
private
environmentService
:
IEnvironment
Service
)
{
}
log
(...
args
:
any
[]):
void
{
const
{
verbose
}
=
this
.
envService
.
cliArgs
;
if
(
verbose
)
{
if
(
this
.
environmentService
.
verbose
)
{
console
.
log
(
`\x1b[93m[main
${
new
Date
().
toLocaleTimeString
()}
]\x1b[0m`
,
...
args
);
}
}
...
...
src/vs/code/electron-main/main.ts
浏览文件 @
05334aea
...
...
@@ -102,7 +102,7 @@ function main(accessor: ServicesAccessor, mainIpcServer: Server, userEnv: IProce
});
logService
.
log
(
'
Starting VS Code in verbose mode
'
);
logService
.
log
(
`from:
${
envService
.
appRoot
}
`
);
logService
.
log
(
`from:
${
env
ironment
Service
.
appRoot
}
`
);
logService
.
log
(
'
args:
'
,
envService
.
cliArgs
);
// Setup Windows mutex
...
...
@@ -134,8 +134,8 @@ function main(accessor: ServicesAccessor, mainIpcServer: Server, userEnv: IProce
// Spawn shared process
const
initData
=
{
args
:
environmentService
.
args
};
const
options
=
{
allowOutput
:
!
env
Service
.
isBuilt
||
envService
.
cliArgs
.
verbose
,
debugPort
:
envService
.
isBuilt
?
null
:
5871
allowOutput
:
!
env
ironmentService
.
isBuilt
||
environmentService
.
verbose
,
debugPort
:
env
ironment
Service
.
isBuilt
?
null
:
5871
};
let
sharedProcessDisposable
;
...
...
src/vs/code/electron-main/storage.ts
浏览文件 @
05334aea
...
...
@@ -7,7 +7,7 @@
import
*
as
path
from
'
path
'
;
import
*
as
fs
from
'
original-fs
'
;
import
{
IEnv
Service
}
from
'
vs/code/electron-main/env
'
;
import
{
IEnv
ironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
export
const
IStorageService
=
createDecorator
<
IStorageService
>
(
'
storageService
'
);
...
...
@@ -26,8 +26,8 @@ export class StorageService implements IStorageService {
private
dbPath
:
string
;
private
database
:
any
=
null
;
constructor
(@
IEnv
Service
private
envService
:
IEnv
Service
)
{
this
.
dbPath
=
path
.
join
(
env
Service
.
appHome
,
'
storage.json
'
);
constructor
(@
IEnv
ironmentService
private
environmentService
:
IEnvironment
Service
)
{
this
.
dbPath
=
path
.
join
(
env
ironmentService
.
userDataPath
,
'
storage.json
'
);
}
getItem
<
T
>
(
key
:
string
,
defaultValue
?:
T
):
T
{
...
...
@@ -74,7 +74,7 @@ export class StorageService implements IStorageService {
try
{
return
JSON
.
parse
(
fs
.
readFileSync
(
this
.
dbPath
).
toString
());
// invalid JSON or permission issue can happen here
}
catch
(
error
)
{
if
(
this
.
env
Service
.
cliArgs
.
verbose
)
{
if
(
this
.
env
ironmentService
.
verbose
)
{
console
.
error
(
error
);
}
...
...
@@ -86,7 +86,7 @@ export class StorageService implements IStorageService {
try
{
fs
.
writeFileSync
(
this
.
dbPath
,
JSON
.
stringify
(
this
.
database
,
null
,
4
));
// permission issue can happen here
}
catch
(
error
)
{
if
(
this
.
env
Service
.
cliArgs
.
verbose
)
{
if
(
this
.
env
ironmentService
.
verbose
)
{
console
.
error
(
error
);
}
}
...
...
src/vs/code/electron-main/window.ts
浏览文件 @
05334aea
...
...
@@ -11,7 +11,8 @@ import * as objects from 'vs/base/common/objects';
import
{
IStorageService
}
from
'
vs/code/electron-main/storage
'
;
import
{
shell
,
screen
,
BrowserWindow
}
from
'
electron
'
;
import
{
TPromise
,
TValueCallback
}
from
'
vs/base/common/winjs.base
'
;
import
{
ICommandLineArguments
,
IEnvService
,
IProcessEnvironment
}
from
'
vs/code/electron-main/env
'
;
import
{
ICommandLineArguments
,
IProcessEnvironment
}
from
'
vs/code/electron-main/env
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
ILogService
}
from
'
vs/code/electron-main/log
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
parseArgs
}
from
'
vs/platform/environment/node/argv
'
;
...
...
@@ -135,7 +136,7 @@ export class VSCodeWindow {
constructor
(
config
:
IWindowCreationOptions
,
@
ILogService
private
logService
:
ILogService
,
@
IEnv
Service
private
envService
:
IEnv
Service
,
@
IEnv
ironmentService
private
environmentService
:
IEnvironment
Service
,
@
IConfigurationService
private
configurationService
:
IConfigurationService
,
@
IStorageService
private
storageService
:
IStorageService
)
{
...
...
@@ -173,7 +174,7 @@ export class VSCodeWindow {
};
if
(
platform
.
isLinux
)
{
options
.
icon
=
path
.
join
(
this
.
envService
.
appRoot
,
'
resources/linux/code.png
'
);
// Windows and Mac are better off using the embedded icon(s)
options
.
icon
=
path
.
join
(
this
.
env
ironment
Service
.
appRoot
,
'
resources/linux/code.png
'
);
// Windows and Mac are better off using the embedded icon(s)
}
// Create the browser window.
...
...
@@ -340,7 +341,7 @@ export class VSCodeWindow {
// Prevent any kind of navigation triggered by the user!
// But do not touch this in dev version because it will prevent "Reload" from dev tools
if
(
this
.
envService
.
isBuilt
)
{
if
(
this
.
env
ironment
Service
.
isBuilt
)
{
this
.
_win
.
webContents
.
on
(
'
will-navigate
'
,
(
event
:
Event
)
=>
{
if
(
event
)
{
event
.
preventDefault
();
...
...
@@ -375,7 +376,7 @@ export class VSCodeWindow {
this
.
_win
.
loadURL
(
this
.
getUrl
(
config
));
// Make window visible if it did not open in N seconds because this indicates an error
if
(
!
this
.
envService
.
isBuilt
)
{
if
(
!
this
.
env
ironment
Service
.
isBuilt
)
{
this
.
showTimeoutHandle
=
setTimeout
(()
=>
{
if
(
this
.
_win
&&
!
this
.
_win
.
isVisible
()
&&
!
this
.
_win
.
isMinimized
())
{
this
.
_win
.
show
();
...
...
src/vs/code/electron-main/windows.ts
浏览文件 @
05334aea
...
...
@@ -14,6 +14,7 @@ import * as types from 'vs/base/common/types';
import
*
as
arrays
from
'
vs/base/common/arrays
'
;
import
{
assign
,
mixin
}
from
'
vs/base/common/objects
'
;
import
{
EventEmitter
}
from
'
events
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
IStorageService
}
from
'
vs/code/electron-main/storage
'
;
import
{
IPath
,
VSCodeWindow
,
ReadyState
,
IWindowConfiguration
,
IWindowState
as
ISingleWindowState
,
defaultWindowState
,
IWindowSettings
}
from
'
vs/code/electron-main/window
'
;
import
{
ipcMain
as
ipc
,
app
,
screen
,
crashReporter
,
BrowserWindow
,
dialog
}
from
'
electron
'
;
...
...
@@ -162,6 +163,7 @@ export class WindowsManager implements IWindowsService {
@
ILogService
private
logService
:
ILogService
,
@
IStorageService
private
storageService
:
IStorageService
,
@
IEnvService
private
envService
:
IEnvService
,
@
IEnvironmentService
private
environmentService
:
IEnvironmentService
,
@
ILifecycleService
private
lifecycleService
:
ILifecycleService
,
@
IUpdateService
private
updateService
:
IUpdateService
,
@
IConfigurationService
private
configurationService
:
IConfigurationService
...
...
@@ -843,7 +845,7 @@ export class WindowsManager implements IWindowsService {
private
toConfiguration
(
userEnv
:
IProcessEnvironment
,
cli
:
ICommandLineArguments
,
workspacePath
?:
string
,
filesToOpen
?:
IPath
[],
filesToCreate
?:
IPath
[],
filesToDiff
?:
IPath
[]):
IWindowConfiguration
{
const
configuration
:
IWindowConfiguration
=
mixin
({},
cli
);
// inherit all properties from CLI
configuration
.
appRoot
=
this
.
envService
.
appRoot
;
configuration
.
appRoot
=
this
.
env
ironment
Service
.
appRoot
;
configuration
.
execPath
=
process
.
execPath
;
configuration
.
userEnv
=
userEnv
;
configuration
.
workspacePath
=
workspacePath
;
...
...
src/vs/platform/environment/common/environment.ts
浏览文件 @
05334aea
...
...
@@ -34,6 +34,7 @@ export interface IEnvironmentService {
isBuilt
:
boolean
;
verbose
:
boolean
;
wait
:
boolean
;
performance
:
boolean
;
mainIPCHandle
:
string
;
...
...
src/vs/platform/environment/node/environmentService.ts
浏览文件 @
05334aea
...
...
@@ -89,6 +89,7 @@ export class EnvironmentService implements IEnvironmentService {
get
isBuilt
():
boolean
{
return
!
process
.
env
[
'
VSCODE_DEV
'
];
}
get
verbose
():
boolean
{
return
this
.
_args
.
verbose
;
}
get
wait
():
boolean
{
return
this
.
_args
.
wait
;
}
get
performance
():
boolean
{
return
this
.
_args
.
performance
;
}
get
logExtensionHostCommunication
():
boolean
{
return
this
.
_args
.
logExtensionHostCommunication
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录