Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
92ee0d1e
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,发现更多精彩内容 >>
提交
92ee0d1e
编写于
3月 21, 2017
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
🍎
⏪
remove legacy cli check
fixes #22366
上级
6b1ae533
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
20 addition
and
123 deletion
+20
-123
src/vs/workbench/parts/cli/electron-browser/cli.contribution.ts
.../workbench/parts/cli/electron-browser/cli.contribution.ts
+20
-123
未找到文件。
src/vs/workbench/parts/cli/electron-browser/cli.contribution.ts
浏览文件 @
92ee0d1e
...
...
@@ -5,7 +5,6 @@
import
*
as
nls
from
'
vs/nls
'
;
import
*
as
path
from
'
path
'
;
import
*
as
os
from
'
os
'
;
import
*
as
cp
from
'
child_process
'
;
import
*
as
pfs
from
'
vs/base/node/pfs
'
;
import
{
nfcall
}
from
'
vs/base/common/async
'
;
...
...
@@ -13,12 +12,10 @@ import { TPromise } from 'vs/base/common/winjs.base';
import
URI
from
'
vs/base/common/uri
'
;
import
{
Action
}
from
'
vs/base/common/actions
'
;
import
{
IWorkbenchActionRegistry
,
Extensions
as
ActionExtensions
}
from
'
vs/workbench/common/actionRegistry
'
;
import
{
IWorkbenchContributionsRegistry
,
IWorkbenchContribution
,
Extensions
as
WorkbenchExtensions
}
from
'
vs/workbench/common/contributions
'
;
import
{
Registry
}
from
'
vs/platform/platform
'
;
import
{
SyncActionDescriptor
}
from
'
vs/platform/actions/common/actions
'
;
import
{
IMessageService
,
Severity
}
from
'
vs/platform/message/common/message
'
;
import
{
IEditorService
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
product
from
'
vs/platform/node/product
'
;
interface
ILegacyUse
{
...
...
@@ -30,10 +27,6 @@ function ignore<T>(code: string, value: T = null): (err: any) => TPromise<T> {
return
err
=>
err
.
code
===
code
?
TPromise
.
as
<
T
>
(
value
)
:
TPromise
.
wrapError
<
T
>
(
err
);
}
function
readOrEmpty
(
name
:
string
):
TPromise
<
string
>
{
return
pfs
.
readFile
(
name
,
'
utf8
'
).
then
(
null
,
ignore
(
'
ENOENT
'
,
''
));
}
const
root
=
URI
.
parse
(
require
.
toUrl
(
''
)).
fsPath
;
const
source
=
path
.
resolve
(
root
,
'
..
'
,
'
bin
'
,
'
code
'
);
...
...
@@ -67,61 +60,28 @@ class InstallAction extends Action {
return
undefined
;
}
return
this
.
checkLegacy
()
.
then
(
uses
=>
{
if
(
uses
.
length
>
0
)
{
const
{
file
,
lineNumber
}
=
uses
[
0
];
const
message
=
nls
.
localize
(
'
exists
'
,
"
Please remove the alias referencing '{0}' in '{1}' (line {2}) and retry this action.
"
,
product
.
darwinBundleIdentifier
,
file
,
lineNumber
);
const
resource
=
URI
.
file
(
file
);
const
input
=
{
resource
};
const
actions
=
[
new
Action
(
'
inlineEdit
'
,
nls
.
localize
(
'
editFile
'
,
"
Edit '{0}'
"
,
file
),
''
,
true
,
()
=>
{
return
this
.
editorService
.
openEditor
(
input
).
then
(()
=>
{
const
message
=
nls
.
localize
(
'
again
'
,
"
Please remove the '{0}' alias from '{1}' before continuing.
"
,
product
.
applicationName
,
file
);
const
actions
=
[
new
Action
(
'
continue
'
,
nls
.
localize
(
'
continue
'
,
"
Continue
"
),
''
,
true
,
()
=>
this
.
run
()),
new
Action
(
'
cancel
'
,
nls
.
localize
(
'
cancel
'
,
"
Cancel
"
))
];
this
.
messageService
.
show
(
Severity
.
Info
,
{
message
,
actions
});
});
})
];
this
.
messageService
.
show
(
Severity
.
Warning
,
{
message
,
actions
});
return
this
.
isInstalled
()
.
then
(
isInstalled
=>
{
if
(
!
isAvailable
||
isInstalled
)
{
return
TPromise
.
as
(
null
);
}
return
this
.
isInstalled
()
.
then
(
isInstalled
=>
{
if
(
!
isAvailable
||
isInstalled
)
{
return
TPromise
.
as
(
null
);
}
else
{
const
createSymlink
=
()
=>
{
return
pfs
.
unlink
(
this
.
target
)
.
then
(
null
,
ignore
(
'
ENOENT
'
))
.
then
(()
=>
pfs
.
symlink
(
source
,
this
.
target
));
};
return
createSymlink
().
then
(
null
,
err
=>
{
if
(
err
.
code
===
'
EACCES
'
||
err
.
code
===
'
ENOENT
'
)
{
return
this
.
createBinFolder
()
.
then
(()
=>
createSymlink
());
}
return
TPromise
.
wrapError
(
err
);
});
}
else
{
const
createSymlink
=
()
=>
{
return
pfs
.
unlink
(
this
.
target
)
.
then
(
null
,
ignore
(
'
ENOENT
'
))
.
then
(()
=>
pfs
.
symlink
(
source
,
this
.
target
));
};
return
createSymlink
().
then
(
null
,
err
=>
{
if
(
err
.
code
===
'
EACCES
'
||
err
.
code
===
'
ENOENT
'
)
{
return
this
.
createBinFolder
()
.
then
(()
=>
createSymlink
());
}
})
.
then
(()
=>
this
.
messageService
.
show
(
Severity
.
Info
,
nls
.
localize
(
'
successIn
'
,
"
Shell command '{0}' successfully installed in PATH.
"
,
product
.
applicationName
)));
});
return
TPromise
.
wrapError
(
err
);
});
}
})
.
then
<
void
>
(()
=>
this
.
messageService
.
show
(
Severity
.
Info
,
nls
.
localize
(
'
successIn
'
,
"
Shell command '{0}' successfully installed in PATH.
"
,
product
.
applicationName
)));
});
}
...
...
@@ -152,32 +112,6 @@ class InstallAction extends Action {
this
.
messageService
.
show
(
Severity
.
Info
,
{
message
,
actions
});
});
}
checkLegacy
():
TPromise
<
ILegacyUse
[]
>
{
const
files
=
[
path
.
join
(
os
.
homedir
(),
'
.bash_profile
'
),
path
.
join
(
os
.
homedir
(),
'
.bashrc
'
),
path
.
join
(
os
.
homedir
(),
'
.zshrc
'
)
];
return
TPromise
.
join
(
files
.
map
(
f
=>
readOrEmpty
(
f
))).
then
(
result
=>
{
return
result
.
reduce
((
result
,
contents
,
index
)
=>
{
const
file
=
files
[
index
];
const
lines
=
contents
.
split
(
/
\r?\n
/
);
lines
.
some
((
line
,
index
)
=>
{
if
(
line
.
indexOf
(
product
.
darwinBundleIdentifier
)
>
-
1
&&
!
/^
\s
*#/
.
test
(
line
))
{
result
.
push
({
file
,
lineNumber
:
index
+
1
});
return
true
;
}
return
false
;
});
return
result
;
},
[]
as
ILegacyUse
[]);
});
}
}
class
UninstallAction
extends
Action
{
...
...
@@ -212,47 +146,10 @@ class UninstallAction extends Action {
}
}
class
DarwinCLIHelper
implements
IWorkbenchContribution
{
constructor
(
@
IInstantiationService
instantiationService
:
IInstantiationService
,
@
IMessageService
messageService
:
IMessageService
)
{
const
installAction
=
instantiationService
.
createInstance
(
InstallAction
,
InstallAction
.
ID
,
InstallAction
.
LABEL
);
isAvailable
().
done
(
isAvailable
=>
{
if
(
!
isAvailable
)
{
return
;
}
return
installAction
.
checkLegacy
().
done
(
files
=>
{
if
(
files
.
length
>
0
)
{
const
message
=
nls
.
localize
(
'
update
'
,
"
Code needs to change the '{0}' shell command. Would you like to do this now?
"
,
product
.
applicationName
);
const
now
=
new
Action
(
'
changeNow
'
,
nls
.
localize
(
'
changeNow
'
,
"
Change Now
"
),
''
,
true
,
()
=>
installAction
.
run
());
const
later
=
new
Action
(
'
later
'
,
nls
.
localize
(
'
later
'
,
"
Later
"
),
''
,
true
,
()
=>
{
messageService
.
show
(
Severity
.
Info
,
nls
.
localize
(
'
laterInfo
'
,
"
Remember you can always run the '{0}' action from the Command Palette.
"
,
installAction
.
label
));
return
null
;
});
const
actions
=
[
now
,
later
];
messageService
.
show
(
Severity
.
Info
,
{
message
,
actions
});
}
});
});
}
getId
():
string
{
return
'
darwin.cli
'
;
}
}
if
(
process
.
platform
===
'
darwin
'
)
{
const
category
=
nls
.
localize
(
'
shellCommand
'
,
"
Shell Command
"
);
const
workbenchActionsRegistry
=
Registry
.
as
<
IWorkbenchActionRegistry
>
(
ActionExtensions
.
WorkbenchActions
);
workbenchActionsRegistry
.
registerWorkbenchAction
(
new
SyncActionDescriptor
(
InstallAction
,
InstallAction
.
ID
,
InstallAction
.
LABEL
),
'
Shell Command: Install
\'
code
\'
command in PATH
'
,
category
);
workbenchActionsRegistry
.
registerWorkbenchAction
(
new
SyncActionDescriptor
(
UninstallAction
,
UninstallAction
.
ID
,
UninstallAction
.
LABEL
),
'
Shell Command: Uninstall
\'
code
\'
command from PATH
'
,
category
);
const
workbenchRegistry
=
Registry
.
as
<
IWorkbenchContributionsRegistry
>
(
WorkbenchExtensions
.
Workbench
);
workbenchRegistry
.
registerWorkbenchContribution
(
DarwinCLIHelper
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录