Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
f4c2b202
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,发现更多精彩内容 >>
提交
f4c2b202
编写于
11月 15, 2018
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
debt: remove TPromise from cli
related to #62716
上级
4ccfe198
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
13 addition
and
16 deletion
+13
-16
src/vs/code/node/cli.ts
src/vs/code/node/cli.ts
+13
-16
未找到文件。
src/vs/code/node/cli.ts
浏览文件 @
f4c2b202
...
...
@@ -4,7 +4,6 @@
*--------------------------------------------------------------------------------------------*/
import
{
spawn
,
ChildProcess
}
from
'
child_process
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
assign
}
from
'
vs/base/common/objects
'
;
import
{
parseCLIProcessArgv
,
buildHelpMessage
}
from
'
vs/platform/environment/node/argv
'
;
import
{
ParsedArgs
}
from
'
vs/platform/environment/common/environment
'
;
...
...
@@ -30,7 +29,7 @@ function shouldSpawnCliProcess(argv: ParsedArgs): boolean {
}
interface
IMainCli
{
main
:
(
argv
:
ParsedArgs
)
=>
T
Promis
e
<
void
>
;
main
:
(
argv
:
ParsedArgs
)
=>
T
henabl
e
<
void
>
;
}
export
async
function
main
(
argv
:
string
[]):
Promise
<
any
>
{
...
...
@@ -40,7 +39,7 @@ export async function main(argv: string[]): Promise<any> {
args
=
parseCLIProcessArgv
(
argv
);
}
catch
(
err
)
{
console
.
error
(
err
.
message
);
return
TPromise
.
as
(
null
)
;
return
;
}
// Help
...
...
@@ -55,8 +54,9 @@ export async function main(argv: string[]): Promise<any> {
// Extensions Management
else
if
(
shouldSpawnCliProcess
(
args
))
{
const
mainCli
=
new
TPromise
<
IMainCli
>
(
c
=>
require
([
'
vs/code/node/cliProcessMain
'
],
c
));
return
mainCli
.
then
(
cli
=>
cli
.
main
(
args
));
const
cli
=
await
new
Promise
<
IMainCli
>
((
c
,
e
)
=>
require
([
'
vs/code/node/cliProcessMain
'
],
c
,
e
));
await
cli
.
main
(
args
);
return
;
}
// Write File
...
...
@@ -71,7 +71,7 @@ export async function main(argv: string[]): Promise<any> {
!
fs
.
existsSync
(
source
)
||
!
fs
.
statSync
(
source
).
isFile
()
||
// make sure source exists as file
!
fs
.
existsSync
(
target
)
||
!
fs
.
statSync
(
target
).
isFile
()
// make sure target exists as file
)
{
return
TPromise
.
wrapError
(
new
Error
(
'
Using --file-write with invalid arguments.
'
)
);
throw
new
Error
(
'
Using --file-write with invalid arguments.
'
);
}
try
{
...
...
@@ -107,10 +107,9 @@ export async function main(argv: string[]): Promise<any> {
fs
.
chmodSync
(
target
,
targetMode
);
}
}
catch
(
error
)
{
return
TPromise
.
wrapError
(
new
Error
(
`Using --file-write resulted in an error:
${
error
}
`
));
error
.
message
=
`Error using --file-write:
${
error
.
message
}
`
;
throw
error
;
}
return
TPromise
.
as
(
null
);
}
// Just Code
...
...
@@ -128,11 +127,11 @@ export async function main(argv: string[]): Promise<any> {
if
(
verbose
)
{
env
[
'
ELECTRON_ENABLE_LOGGING
'
]
=
'
1
'
;
processCallbacks
.
push
(
child
=>
{
processCallbacks
.
push
(
async
child
=>
{
child
.
stdout
.
on
(
'
data
'
,
(
data
:
Buffer
)
=>
console
.
log
(
data
.
toString
(
'
utf8
'
).
trim
()));
child
.
stderr
.
on
(
'
data
'
,
(
data
:
Buffer
)
=>
console
.
log
(
data
.
toString
(
'
utf8
'
).
trim
()));
return
new
TPromise
<
void
>
(
c
=>
child
.
once
(
'
exit
'
,
()
=>
c
(
void
0
)));
await
new
Promise
(
c
=>
child
.
once
(
'
exit
'
,
()
=>
c
(
)));
});
}
...
...
@@ -199,7 +198,7 @@ export async function main(argv: string[]): Promise<any> {
// If the user pipes data via stdin but forgot to add the "-" argument, help by printing a message
// if we detect that data flows into via stdin after a certain timeout.
else
if
(
args
.
_
.
length
===
0
)
{
processCallbacks
.
push
(
child
=>
new
T
Promise
(
c
=>
{
processCallbacks
.
push
(
child
=>
new
Promise
(
c
=>
{
const
dataListener
=
()
=>
{
if
(
isWindows
)
{
console
.
log
(
`Run with '
${
product
.
applicationName
}
-' to read output from another program (e.g. 'echo Hello World |
${
product
.
applicationName
}
-').`
);
...
...
@@ -358,7 +357,7 @@ export async function main(argv: string[]): Promise<any> {
const
child
=
spawn
(
process
.
execPath
,
argv
.
slice
(
2
),
options
);
if
(
args
.
wait
&&
waitMarkerFilePath
)
{
return
new
T
Promise
<
void
>
(
c
=>
{
return
new
Promise
<
void
>
(
c
=>
{
// Complete when process exits
child
.
once
(
'
exit
'
,
()
=>
c
(
void
0
));
...
...
@@ -374,10 +373,8 @@ export async function main(argv: string[]): Promise<any> {
});
}
return
TPromise
.
join
(
processCallbacks
.
map
(
callback
=>
callback
(
child
)));
return
Promise
.
all
(
processCallbacks
.
map
(
callback
=>
callback
(
child
)));
}
return
TPromise
.
as
(
null
);
}
function
eventuallyExit
(
code
:
number
):
void
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录