Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
ec0250d2
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,发现更多精彩内容 >>
提交
ec0250d2
编写于
12月 01, 2017
作者:
E
Erich Gamma
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add launch configs to the workspace state
上级
8d834971
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
66 addition
and
23 deletion
+66
-23
src/vs/base/node/stats.ts
src/vs/base/node/stats.ts
+39
-10
src/vs/code/electron-main/diagnostics.ts
src/vs/code/electron-main/diagnostics.ts
+27
-13
未找到文件。
src/vs/base/node/stats.ts
浏览文件 @
ec0250d2
...
...
@@ -5,17 +5,52 @@
'
use strict
'
;
import
{
readdirSync
,
statSync
}
from
'
fs
'
;
import
{
readdirSync
,
statSync
,
existsSync
,
readFileSync
}
from
'
fs
'
;
import
{
join
}
from
'
path
'
;
export
interface
WorkspaceStatItem
{
name
:
string
;
value
:
number
;
count
:
number
;
}
export
interface
WorkspaceStats
{
fileTypes
:
WorkspaceStatItem
[];
configFiles
:
WorkspaceStatItem
[];
}
function
asSortedItems
(
map
:
Map
<
string
,
number
>
):
WorkspaceStatItem
[]
{
let
a
:
WorkspaceStatItem
[]
=
[];
map
.
forEach
((
value
,
index
)
=>
a
.
push
({
name
:
index
,
count
:
value
}));
return
a
.
sort
((
a
,
b
)
=>
b
.
count
-
a
.
count
);
}
export
function
collectLaunchConfigs
(
folder
:
string
):
WorkspaceStatItem
[]
{
let
launchConfigs
=
new
Map
<
string
,
number
>
();
let
launchConfig
=
join
(
folder
,
'
.vscode
'
,
'
launch.json
'
);
if
(
existsSync
(
launchConfig
))
{
try
{
const
contents
=
readFileSync
(
launchConfig
).
toString
();
const
json
=
JSON
.
parse
(
contents
);
if
(
json
[
'
configurations
'
])
{
for
(
const
each
of
json
[
'
configurations
'
])
{
const
type
=
each
[
'
type
'
];
if
(
type
)
{
if
(
launchConfigs
.
has
(
type
))
{
launchConfigs
.
set
(
type
,
launchConfigs
.
get
(
type
)
+
1
);
}
else
{
launchConfigs
.
set
(
type
,
1
);
}
}
}
}
}
catch
{
}
}
return
asSortedItems
(
launchConfigs
);
}
export
function
collectWorkspaceStats
(
folder
:
string
,
filter
:
string
[]):
WorkspaceStats
{
const
configFilePatterns
=
[
{
'
tag
'
:
'
grunt.js
'
,
'
pattern
'
:
/^
gruntfile
\
.
js$
/
i
},
...
...
@@ -42,9 +77,9 @@ export function collectWorkspaceStats(folder: string, filter: string[]): Workspa
let
walkSync
=
(
dir
:
string
,
acceptFile
:
(
fileName
:
string
)
=>
void
,
filter
:
string
[])
=>
{
let
files
=
readdirSync
(
dir
);
for
(
const
file
of
files
)
{
if
(
statSync
(
dir
+
'
/
'
+
file
).
isDirectory
())
{
if
(
statSync
(
join
(
dir
,
file
)
).
isDirectory
())
{
if
(
filter
.
indexOf
(
file
)
===
-
1
)
{
walkSync
(
dir
+
'
/
'
+
file
,
acceptFile
,
filter
);
walkSync
(
join
(
dir
,
file
)
,
acceptFile
,
filter
);
}
}
else
{
...
...
@@ -84,12 +119,6 @@ export function collectWorkspaceStats(folder: string, filter: string[]): Workspa
addConfigFiles
(
name
);
};
let
asSortedItems
=
(
map
:
Map
<
string
,
number
>
):
WorkspaceStatItem
[]
=>
{
let
a
:
WorkspaceStatItem
[]
=
[];
map
.
forEach
((
value
,
index
)
=>
a
.
push
({
name
:
index
,
value
:
value
}));
return
a
.
sort
((
a
,
b
)
=>
b
.
value
-
a
.
value
);
};
walkSync
(
folder
,
acceptFile
,
filter
);
let
result
=
{
...
...
src/vs/code/electron-main/diagnostics.ts
浏览文件 @
ec0250d2
...
...
@@ -5,7 +5,7 @@
'
use strict
'
;
import
{
WorkspaceStats
,
collectWorkspaceStats
}
from
'
vs/base/node/stats
'
;
import
{
WorkspaceStats
,
collectWorkspaceStats
,
collectLaunchConfigs
,
WorkspaceStatItem
}
from
'
vs/base/node/stats
'
;
import
{
IMainProcessInfo
}
from
'
vs/code/electron-main/launch
'
;
import
{
ProcessItem
,
listProcesses
}
from
'
vs/base/node/ps
'
;
import
product
from
'
vs/platform/node/product
'
;
...
...
@@ -43,6 +43,11 @@ export function printDiagnostics(info: IMainProcessInfo): Promise<any> {
console
.
log
(
`| Folder (
${
basename
(
folder
)}
)`
);
const
stats
=
collectWorkspaceStats
(
folder
,
[
'
node_modules
'
,
'
.git
'
]);
console
.
log
(
formatWorkspaceStats
(
stats
));
const
launchConfigs
=
collectLaunchConfigs
(
folder
);
if
(
launchConfigs
.
length
>
0
)
{
console
.
log
(
formatLaunchConfigs
(
launchConfigs
));
}
});
});
}
...
...
@@ -56,8 +61,9 @@ function formatWorkspaceStats(workspaceStats: WorkspaceStats): string {
const
lineLength
=
60
;
let
col
=
0
;
const
appendAndWrap
=
(
index
:
string
,
value
:
number
)
=>
{
const
item
=
`
${
index
}
(
${
value
}
)`
;
const
appendAndWrap
=
(
name
:
string
,
count
:
number
)
=>
{
const
item
=
count
>
1
?
`
${
name
}
(
${
count
}
)`
:
`
${
name
}
`
;
if
(
col
+
item
.
length
>
lineLength
)
{
output
.
push
(
line
);
line
=
'
|
'
;
...
...
@@ -81,21 +87,29 @@ function formatWorkspaceStats(workspaceStats: WorkspaceStats): string {
output
.
push
(
line
);
// Conf Files
line
=
'
| Conf files:
'
;
col
=
0
;
let
hasConfFiles
=
false
;
workspaceStats
.
configFiles
.
forEach
((
item
)
=>
{
hasConfFiles
=
true
;
appendAndWrap
(
item
.
name
,
item
.
value
);
});
if
(
!
hasConfFiles
)
{
line
=
`
${
line
}
<not enough data>`
;
if
(
workspaceStats
.
configFiles
.
length
>=
0
)
{
line
=
'
| Conf files:
'
;
col
=
0
;
workspaceStats
.
configFiles
.
forEach
((
item
)
=>
{
appendAndWrap
(
item
.
name
,
item
.
count
);
});
output
.
push
(
line
);
}
output
.
push
(
line
);
return
output
.
join
(
'
\n
'
);
}
function
formatLaunchConfigs
(
configs
:
WorkspaceStatItem
[]):
string
{
const
output
:
string
[]
=
[];
let
line
=
'
| Launch Configs:
'
;
configs
.
forEach
(
each
=>
{
const
item
=
each
.
count
>
1
?
`
${
each
.
name
}
(
${
each
.
count
}
)`
:
`
${
each
.
name
}
`
;
line
+=
item
;
});
output
.
push
(
line
);
return
output
.
join
(
'
\n
'
);
}
function
formatEnvironment
(
info
:
IMainProcessInfo
):
string
{
const
MB
=
1024
*
1024
;
const
GB
=
1024
*
MB
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录