Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
gzupanda
code-server
提交
c10450c4
C
code-server
项目概览
gzupanda
/
code-server
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
code-server
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
c10450c4
编写于
11月 03, 2020
作者:
A
Asher
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move isFile into util
That allows its use in entry.ts as well.
上级
c72c53f6
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
14 addition
and
24 deletion
+14
-24
src/node/entry.ts
src/node/entry.ts
+4
-14
src/node/util.ts
src/node/util.ts
+9
-0
src/node/vscode.ts
src/node/vscode.ts
+1
-10
未找到文件。
src/node/entry.ts
浏览文件 @
c10450c4
import
{
field
,
logger
}
from
"
@coder/logger
"
import
*
as
cp
from
"
child_process
"
import
{
promises
as
fs
}
from
"
fs
"
import
http
from
"
http
"
import
*
as
path
from
"
path
"
import
{
CliMessage
,
OpenCommandPipeArgs
}
from
"
../../lib/vscode/src/vs/server/ipc
"
...
...
@@ -19,7 +18,7 @@ import {
import
{
coderCloudBind
}
from
"
./coder-cloud
"
import
{
commit
,
version
}
from
"
./constants
"
import
{
register
}
from
"
./routes
"
import
{
humanPath
,
open
}
from
"
./util
"
import
{
humanPath
,
isFile
,
open
}
from
"
./util
"
import
{
ipcMain
,
WrapperProcess
}
from
"
./wrapper
"
export
const
runVsCodeCli
=
(
args
:
DefaultedArgs
):
void
=>
{
...
...
@@ -55,21 +54,12 @@ export const openInExistingInstance = async (args: DefaultedArgs, socketPath: st
forceNewWindow
:
args
[
"
new-window
"
],
}
const
isDir
=
async
(
path
:
string
):
Promise
<
boolean
>
=>
{
try
{
const
st
=
await
fs
.
stat
(
path
)
return
st
.
isDirectory
()
}
catch
(
error
)
{
return
false
}
}
for
(
let
i
=
0
;
i
<
args
.
_
.
length
;
i
++
)
{
const
fp
=
path
.
resolve
(
args
.
_
[
i
])
if
(
await
isDir
(
fp
))
{
pipeArgs
.
folderURIs
.
push
(
fp
)
}
else
{
if
(
await
isFile
(
fp
))
{
pipeArgs
.
fileURIs
.
push
(
fp
)
}
else
{
pipeArgs
.
folderURIs
.
push
(
fp
)
}
}
...
...
src/node/util.ts
浏览文件 @
c10450c4
...
...
@@ -261,3 +261,12 @@ export function canConnect(path: string): Promise<boolean> {
})
})
}
export
const
isFile
=
async
(
path
:
string
):
Promise
<
boolean
>
=>
{
try
{
const
stat
=
await
fs
.
stat
(
path
)
return
stat
.
isFile
()
}
catch
(
error
)
{
return
false
}
}
src/node/vscode.ts
浏览文件 @
c10450c4
import
{
field
,
logger
}
from
"
@coder/logger
"
import
*
as
cp
from
"
child_process
"
import
*
as
fs
from
"
fs-extra
"
import
*
as
net
from
"
net
"
import
*
as
path
from
"
path
"
import
*
as
ipc
from
"
../../lib/vscode/src/vs/server/ipc
"
import
{
arrayify
,
generateUuid
}
from
"
../common/util
"
import
{
rootPath
}
from
"
./constants
"
import
{
settings
}
from
"
./settings
"
import
{
isFile
}
from
"
./util
"
export
class
VscodeProvider
{
public
readonly
serverRootPath
:
string
...
...
@@ -123,15 +123,6 @@ export class VscodeProvider {
private
async
getFirstPath
(
startPaths
:
Array
<
{
url
?:
string
|
string
[]
|
ipc
.
Query
|
ipc
.
Query
[];
workspace
?:
boolean
}
|
undefined
>
,
):
Promise
<
ipc
.
StartPath
|
undefined
>
{
const
isFile
=
async
(
path
:
string
):
Promise
<
boolean
>
=>
{
try
{
const
stat
=
await
fs
.
stat
(
path
)
return
stat
.
isFile
()
}
catch
(
error
)
{
logger
.
warn
(
error
.
message
)
return
false
}
}
for
(
let
i
=
0
;
i
<
startPaths
.
length
;
++
i
)
{
const
startPath
=
startPaths
[
i
]
const
url
=
arrayify
(
startPath
&&
startPath
.
url
).
find
((
p
)
=>
!!
p
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录