Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
彭彦祖
code-server
提交
b30aefcf
C
code-server
项目概览
彭彦祖
/
code-server
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
1
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 搜索 >>
未验证
提交
b30aefcf
编写于
2月 04, 2020
作者:
A
Asher
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add linting steps and improve testing steps
上级
b29346ec
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
174 addition
and
86 deletion
+174
-86
.drone.yml
.drone.yml
+90
-53
package.json
package.json
+2
-1
scripts/cacher.sh
scripts/cacher.sh
+12
-1
scripts/ci.bash
scripts/ci.bash
+1
-4
scripts/test.sh
scripts/test.sh
+19
-0
src/node/entry.ts
src/node/entry.ts
+16
-2
src/node/wrapper.ts
src/node/wrapper.ts
+34
-25
未找到文件。
.drone.yml
浏览文件 @
b30aefcf
...
@@ -6,22 +6,30 @@ platform:
...
@@ -6,22 +6,30 @@ platform:
arch
:
amd64
arch
:
amd64
steps
:
steps
:
-
name
:
submodules
-
name
:
cache:restore
image
:
alpine/git
image
:
codercom/nbin:centos
commands
:
commands
:
-
git submodule update --init
-
yum install -y libxkbfile-devel libsecret-devel
-
. /opt/rh/devtoolset-6/enable
-
./scripts/cacher.sh
-
name
:
cache:restore
-
name
:
lint
image
:
node:12
image
:
node:12
commands
:
commands
:
-
./scripts/cacher.sh
-
yarn lint
-
name
:
test
image
:
codercom/nbin:centos
commands
:
-
yum install -y openssl
-
yarn test
-
name
:
build
-
name
:
build
image
:
codercom/nbin:centos
image
:
codercom/nbin:centos
commands
:
commands
:
-
yum install -y libxkbfile-devel libsecret-devel
-
yum install -y libxkbfile-devel libsecret-devel
-
. /opt/rh/devtoolset-6/enable
-
. /opt/rh/devtoolset-6/enable
-
timeout 50m ./scripts/ci.bash || echo 'Timed out or failed; continuing
so we can
preserve cache for the next run'
-
timeout 50m ./scripts/ci.bash || echo 'Timed out or failed; continuing
to
preserve cache for the next run'
-
name
:
cache:package
-
name
:
cache:package
image
:
node:12
image
:
node:12
...
@@ -40,10 +48,10 @@ steps:
...
@@ -40,10 +48,10 @@ steps:
when
:
when
:
event
:
push
event
:
push
-
name
:
test
-
name
:
test
:build
image
:
node:12
image
:
codercom/nbin:centos
commands
:
commands
:
-
yarn test
-
yarn test
:build
-
name
:
publish:github
-
name
:
publish:github
image
:
plugins/github-release
image
:
plugins/github-release
...
@@ -90,21 +98,28 @@ platform:
...
@@ -90,21 +98,28 @@ platform:
arch
:
amd64
arch
:
amd64
steps
:
steps
:
-
name
:
submodules
image
:
alpine/git
commands
:
-
git submodule update --init
-
name
:
cache:restore
-
name
:
cache:restore
image
:
node:12-alpine
image
:
node:12-alpine
commands
:
commands
:
-
apk add libxkbfile-dev libsecret-dev build-base git bash python
-
./scripts/cacher.sh
-
./scripts/cacher.sh
-
name
:
lint
image
:
node:12-alpine
commands
:
-
yarn lint
-
name
:
test
image
:
node:12-alpine
commands
:
-
apk add openssl
-
yarn test
-
name
:
build
-
name
:
build
image
:
node:12-alpine
image
:
node:12-alpine
commands
:
commands
:
-
apk add libxkbfile-dev libsecret-dev build-base git bash python
-
apk add libxkbfile-dev libsecret-dev build-base git bash python
-
timeout 50m ./scripts/ci.bash || echo 'Timed out or failed; continuing
so we can
preserve cache for the next run'
-
timeout 50m ./scripts/ci.bash || echo 'Timed out or failed; continuing
to
preserve cache for the next run'
-
name
:
cache:package
-
name
:
cache:package
image
:
node:12-alpine
image
:
node:12-alpine
...
@@ -123,10 +138,10 @@ steps:
...
@@ -123,10 +138,10 @@ steps:
when
:
when
:
event
:
push
event
:
push
-
name
:
test
-
name
:
test
:build
image
:
node:12-alpine
image
:
node:12-alpine
commands
:
commands
:
-
yarn test
-
yarn test
:build
-
name
:
publish:github
-
name
:
publish:github
image
:
plugins/github-release
image
:
plugins/github-release
...
@@ -159,22 +174,27 @@ platform:
...
@@ -159,22 +174,27 @@ platform:
arch
:
arm64
arch
:
arm64
steps
:
steps
:
-
name
:
submodules
image
:
alpine
commands
:
-
apk add git
-
git submodule update --init
-
name
:
cache:restore
-
name
:
cache:restore
image
:
node:12
image
:
node:12
commands
:
commands
:
-
apt update && apt install -y build-essential git libsecret-1-dev libx11-dev libxkbfile-dev
-
./scripts/cacher.sh
-
./scripts/cacher.sh
-
name
:
lint
image
:
node:12
commands
:
-
yarn lint
-
name
:
test
image
:
node:12
commands
:
-
yarn test
-
name
:
build
-
name
:
build
image
:
node:12
image
:
node:12
commands
:
commands
:
-
apt update && apt install -y build-essential git libsecret-1-dev libx11-dev libxkbfile-dev
-
apt update && apt install -y build-essential git libsecret-1-dev libx11-dev libxkbfile-dev
-
timeout 50m ./scripts/ci.bash || echo 'Timed out or failed; continuing
so we can
preserve cache for the next run'
-
timeout 50m ./scripts/ci.bash || echo 'Timed out or failed; continuing
to
preserve cache for the next run'
-
name
:
cache:package
-
name
:
cache:package
image
:
node:12
image
:
node:12
...
@@ -193,10 +213,10 @@ steps:
...
@@ -193,10 +213,10 @@ steps:
when
:
when
:
event
:
push
event
:
push
-
name
:
test
-
name
:
test
:build
image
:
node:12
image
:
node:12
commands
:
commands
:
-
yarn test
-
yarn test
:build
-
name
:
publish:github
-
name
:
publish:github
image
:
plugins/github-release
image
:
plugins/github-release
...
@@ -243,22 +263,28 @@ platform:
...
@@ -243,22 +263,28 @@ platform:
arch
:
arm64
arch
:
arm64
steps
:
steps
:
-
name
:
submodules
image
:
alpine
commands
:
-
apk add git
-
git submodule update --init
-
name
:
cache:restore
-
name
:
cache:restore
image
:
node:12-alpine
image
:
node:12-alpine
commands
:
commands
:
-
apk add libxkbfile-dev libsecret-dev build-base git bash python
-
./scripts/cacher.sh
-
./scripts/cacher.sh
-
name
:
lint
image
:
node:12-alpine
commands
:
-
yarn lint
-
name
:
test
image
:
node:12-alpine
commands
:
-
apk add openssl
-
yarn test
-
name
:
build
-
name
:
build
image
:
node:12-alpine
image
:
node:12-alpine
commands
:
commands
:
-
apk add libxkbfile-dev libsecret-dev build-base git bash python
-
apk add libxkbfile-dev libsecret-dev build-base git bash python
-
timeout 50m ./scripts/ci.bash || echo 'Timed out or failed; continuing
so we can
preserve cache for the next run'
-
timeout 50m ./scripts/ci.bash || echo 'Timed out or failed; continuing
to
preserve cache for the next run'
-
name
:
cache:package
-
name
:
cache:package
image
:
node:12-alpine
image
:
node:12-alpine
...
@@ -277,10 +303,10 @@ steps:
...
@@ -277,10 +303,10 @@ steps:
when
:
when
:
event
:
push
event
:
push
-
name
:
test
-
name
:
test
:build
image
:
node:12-alpine
image
:
node:12-alpine
commands
:
commands
:
-
yarn test
-
yarn test
:build
-
name
:
publish:github
-
name
:
publish:github
image
:
plugins/github-release
image
:
plugins/github-release
...
@@ -313,22 +339,27 @@ platform:
...
@@ -313,22 +339,27 @@ platform:
arch
:
arm
arch
:
arm
steps
:
steps
:
-
name
:
submodules
image
:
alpine
commands
:
-
apk add git
-
git submodule update --init
-
name
:
cache:restore
-
name
:
cache:restore
image
:
node:12
image
:
node:12
commands
:
commands
:
-
apt update && apt install -y build-essential git libsecret-1-dev libx11-dev libxkbfile-dev
-
./scripts/cacher.sh
-
./scripts/cacher.sh
-
name
:
lint
image
:
node:12
commands
:
-
yarn lint
-
name
:
test
image
:
node:12
commands
:
-
yarn test
-
name
:
build
-
name
:
build
image
:
node:12
image
:
node:12
commands
:
commands
:
-
apt update && apt install -y build-essential git libsecret-1-dev libx11-dev libxkbfile-dev
-
apt update && apt install -y build-essential git libsecret-1-dev libx11-dev libxkbfile-dev
-
timeout 50m ./scripts/ci.bash || echo 'Timed out or failed; continuing
so we can
preserve cache for the next run'
-
timeout 50m ./scripts/ci.bash || echo 'Timed out or failed; continuing
to
preserve cache for the next run'
-
name
:
cache:package
-
name
:
cache:package
image
:
node:12
image
:
node:12
...
@@ -347,11 +378,11 @@ steps:
...
@@ -347,11 +378,11 @@ steps:
when
:
when
:
event
:
push
event
:
push
-
name
:
test
-
name
:
test
:build
image
:
node:12
image
:
node:12
failure
:
ignore
failure
:
ignore
commands
:
commands
:
-
yarn test
-
yarn test
:build
# - name: publish:github
# - name: publish:github
# image: plugins/github-release
# image: plugins/github-release
...
@@ -388,22 +419,28 @@ platform:
...
@@ -388,22 +419,28 @@ platform:
arch
:
arm
arch
:
arm
steps
:
steps
:
-
name
:
submodules
image
:
alpine
commands
:
-
apk add git
-
git submodule update --init
-
name
:
cache:restore
-
name
:
cache:restore
image
:
node:12-alpine
image
:
node:12-alpine
commands
:
commands
:
-
apk add libxkbfile-dev libsecret-dev build-base git bash python
-
./scripts/cacher.sh
-
./scripts/cacher.sh
-
name
:
lint
image
:
node:12-alpine
commands
:
-
yarn lint
-
name
:
test
image
:
node:12-alpine
commands
:
-
apk add openssl
-
yarn test
-
name
:
build
-
name
:
build
image
:
node:12-alpine
image
:
node:12-alpine
commands
:
commands
:
-
apk add libxkbfile-dev libsecret-dev build-base git bash python
-
apk add libxkbfile-dev libsecret-dev build-base git bash python
-
timeout 50m ./scripts/ci.bash || echo 'Timed out or failed; continuing
so we can
preserve cache for the next run'
-
timeout 50m ./scripts/ci.bash || echo 'Timed out or failed; continuing
to
preserve cache for the next run'
-
name
:
cache:package
-
name
:
cache:package
image
:
node:12-alpine
image
:
node:12-alpine
...
@@ -422,11 +459,11 @@ steps:
...
@@ -422,11 +459,11 @@ steps:
when
:
when
:
event
:
push
event
:
push
-
name
:
test
-
name
:
test
:build
image
:
node:12-alpine
image
:
node:12-alpine
failure
:
ignore
failure
:
ignore
commands
:
commands
:
-
yarn test
-
yarn test
:build
# - name: publish:github
# - name: publish:github
# image: plugins/github-release
# image: plugins/github-release
...
...
package.json
浏览文件 @
b30aefcf
...
@@ -9,7 +9,8 @@
...
@@ -9,7 +9,8 @@
"patch:generate"
:
"cd ./lib/vscode && git diff HEAD > ../../scripts/vscode.patch"
,
"patch:generate"
:
"cd ./lib/vscode && git diff HEAD > ../../scripts/vscode.patch"
,
"patch:apply"
:
"cd ./lib/vscode && git apply ../../scripts/vscode.patch"
,
"patch:apply"
:
"cd ./lib/vscode && git apply ../../scripts/vscode.patch"
,
"test"
:
"mocha -r ts-node/register ./test/*.test.ts"
,
"test"
:
"mocha -r ts-node/register ./test/*.test.ts"
,
"lint:js"
:
"eslint {src,test,scripts} --ext .ts,.tsx"
,
"test:build"
:
"./scripts/test.sh"
,
"lint:js"
:
"eslint src test scripts --ext .ts,.tsx"
,
"lint:css"
:
"stylelint 'src/**/*.css'"
,
"lint:css"
:
"stylelint 'src/**/*.css'"
,
"lint"
:
"./scripts/lint.sh"
,
"lint"
:
"./scripts/lint.sh"
,
"watch"
:
"yarn runner watch"
,
"watch"
:
"yarn runner watch"
,
...
...
scripts/cacher.sh
浏览文件 @
b30aefcf
...
@@ -46,7 +46,18 @@ main() {
...
@@ -46,7 +46,18 @@ main() {
# The action is determined by the name of the step.
# The action is determined by the name of the step.
case
$DRONE_STEP_NAME
in
case
$DRONE_STEP_NAME
in
*
restore
*
)
restore
"
$branch
"
"
$DRONE_REPO_BRANCH
"
;;
*
restore
*
)
# Sub-modules must be pulled first since extracting the cache directories
# will prevent git from cloning into them.
git submodule update
--init
restore
"
$branch
"
"
$DRONE_REPO_BRANCH
"
# Now make sure the pulled Node modules are up to date.
YARN_CACHE_FOLDER
=
"
$(
pwd
)
/yarn-cache"
export
YARN_CACHE_FOLDER
yarn
;;
*
rebuild
*
|
*
package
*
)
package
"
$branch
"
;;
*
rebuild
*
|
*
package
*
)
package
"
$branch
"
;;
*
)
exit
1
;;
*
)
exit
1
;;
esac
esac
...
...
scripts/ci.bash
浏览文件 @
b30aefcf
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
set
-euo
pipefail
set
-euo
pipefail
# This script assumes that yarn has already ran.
function
main
()
{
function
main
()
{
cd
"
$(
dirname
"
${
0
}
"
)
/.."
cd
"
$(
dirname
"
${
0
}
"
)
/.."
...
@@ -21,10 +22,6 @@ function main() {
...
@@ -21,10 +22,6 @@ function main() {
export
PACKAGE
=
"true"
export
PACKAGE
=
"true"
fi
fi
if
[[
-z
${
SKIP_YARN
:-}
]]
;
then
yarn
fi
yarn build
yarn build
yarn binary
yarn binary
if
[[
-n
${
PACKAGE
:-}
]]
;
then
if
[[
-n
${
PACKAGE
:-}
]]
;
then
...
...
scripts/test.sh
0 → 100755
浏览文件 @
b30aefcf
#!/usr/bin/env sh
# test.sh -- Simple build test.
set
-eu
main
()
{
cd
"
$(
dirname
"
$0
"
)
/.."
# The main goal here is to ensure that the build fully completed and the
# result looks usable.
version
=
$(
node ./build/out/node/entry.js
--version
--json
)
echo
"Got '
$version
' for the version"
case
$version
in
"{ codeServer"
:
*
)
exit
0
;;
*
)
exit
1
;;
esac
}
main
"
$@
"
src/node/entry.ts
浏览文件 @
b30aefcf
...
@@ -49,7 +49,7 @@ const main = async (args: Args = {}): Promise<void> => {
...
@@ -49,7 +49,7 @@ const main = async (args: Args = {}): Promise<void> => {
new
VscodeHttpProvider
([],
{
base
:
"
/vscode-embed
"
,
auth
,
password
})
new
VscodeHttpProvider
([],
{
base
:
"
/vscode-embed
"
,
auth
,
password
})
)
)
ipcMain
.
onDispose
(()
=>
httpServer
.
dispose
())
ipcMain
()
.
onDispose
(()
=>
httpServer
.
dispose
())
const
serverAddress
=
await
httpServer
.
listen
()
const
serverAddress
=
await
httpServer
.
listen
()
logger
.
info
(
`Server listening on
${
serverAddress
}
`
)
logger
.
info
(
`Server listening on
${
serverAddress
}
`
)
...
@@ -84,4 +84,18 @@ const main = async (args: Args = {}): Promise<void> => {
...
@@ -84,4 +84,18 @@ const main = async (args: Args = {}): Promise<void> => {
}
}
}
}
wrap
(
main
)
// TODO: Implement CLI parser.
if
(
process
.
argv
.
includes
(
"
--version
"
))
{
const
version
=
require
(
"
../../package.json
"
).
version
if
(
process
.
argv
.
includes
(
"
--json
"
))
{
console
.
log
({
codeServer
:
version
,
vscode
:
require
(
"
../../lib/vscode/package.json
"
).
version
,
})
}
else
{
console
.
log
(
version
)
}
process
.
exit
(
0
)
}
else
{
wrap
(
main
)
}
src/node/wrapper.ts
浏览文件 @
b30aefcf
...
@@ -21,14 +21,6 @@ export class ProcessError extends Error {
...
@@ -21,14 +21,6 @@ export class ProcessError extends Error {
}
}
}
}
/**
* Ensure we control when the process exits.
*/
const
exit
=
process
.
exit
process
.
exit
=
function
(
code
?:
number
)
{
logger
.
warn
(
`process.exit() was prevented:
${
code
||
"
unknown code
"
}
.`
)
}
as
(
code
?:
number
)
=>
never
/**
/**
* Allows the wrapper and inner processes to communicate.
* Allows the wrapper and inner processes to communicate.
*/
*/
...
@@ -37,19 +29,26 @@ export class IpcMain {
...
@@ -37,19 +29,26 @@ export class IpcMain {
public
readonly
onMessage
=
this
.
_onMessage
.
event
public
readonly
onMessage
=
this
.
_onMessage
.
event
private
readonly
_onDispose
=
new
Emitter
<
NodeJS
.
Signals
|
undefined
>
()
private
readonly
_onDispose
=
new
Emitter
<
NodeJS
.
Signals
|
undefined
>
()
public
readonly
onDispose
=
this
.
_onDispose
.
event
public
readonly
onDispose
=
this
.
_onDispose
.
event
public
readonly
exit
:
(
code
?:
number
)
=>
never
public
constructor
(
public
readonly
parentPid
?:
number
)
{
public
constructor
(
public
readonly
parentPid
?:
number
)
{
process
.
on
(
"
SIGINT
"
,
()
=>
this
.
_onDispose
.
emit
(
"
SIGINT
"
))
process
.
on
(
"
SIGINT
"
,
()
=>
this
.
_onDispose
.
emit
(
"
SIGINT
"
))
process
.
on
(
"
SIGTERM
"
,
()
=>
this
.
_onDispose
.
emit
(
"
SIGTERM
"
))
process
.
on
(
"
SIGTERM
"
,
()
=>
this
.
_onDispose
.
emit
(
"
SIGTERM
"
))
process
.
on
(
"
exit
"
,
()
=>
this
.
_onDispose
.
emit
(
undefined
))
process
.
on
(
"
exit
"
,
()
=>
this
.
_onDispose
.
emit
(
undefined
))
// Ensure we control when the process exits.
this
.
exit
=
process
.
exit
process
.
exit
=
function
(
code
?:
number
)
{
logger
.
warn
(
`process.exit() was prevented:
${
code
||
"
unknown code
"
}
.`
)
}
as
(
code
?:
number
)
=>
never
this
.
onDispose
((
signal
)
=>
{
this
.
onDispose
((
signal
)
=>
{
// Remove listeners to avoid possibly triggering disposal again.
// Remove listeners to avoid possibly triggering disposal again.
process
.
removeAllListeners
()
process
.
removeAllListeners
()
// Let any other handlers run first then exit.
// Let any other handlers run first then exit.
logger
.
debug
(
`
${
parentPid
?
"
inner process
"
:
"
wrapper
"
}
${
process
.
pid
}
disposing`
,
field
(
"
code
"
,
signal
))
logger
.
debug
(
`
${
parentPid
?
"
inner process
"
:
"
wrapper
"
}
${
process
.
pid
}
disposing`
,
field
(
"
code
"
,
signal
))
setTimeout
(()
=>
exit
(
0
),
0
)
setTimeout
(()
=>
this
.
exit
(
0
),
0
)
})
})
// Kill the inner process if the parent dies. This is for the case where the
// Kill the inner process if the parent dies. This is for the case where the
...
@@ -117,9 +116,17 @@ export class IpcMain {
...
@@ -117,9 +116,17 @@ export class IpcMain {
}
}
}
}
export
const
ipcMain
=
new
IpcMain
(
let
_ipcMain
:
IpcMain
typeof
process
.
env
.
CODE_SERVER_PARENT_PID
!==
"
undefined
"
?
parseInt
(
process
.
env
.
CODE_SERVER_PARENT_PID
)
:
undefined
export
const
ipcMain
=
():
IpcMain
=>
{
)
if
(
!
_ipcMain
)
{
_ipcMain
=
new
IpcMain
(
typeof
process
.
env
.
CODE_SERVER_PARENT_PID
!==
"
undefined
"
?
parseInt
(
process
.
env
.
CODE_SERVER_PARENT_PID
)
:
undefined
)
}
return
_ipcMain
}
export
interface
WrapperOptions
{
export
interface
WrapperOptions
{
maxMemory
?:
number
maxMemory
?:
number
...
@@ -135,14 +142,14 @@ export class WrapperProcess {
...
@@ -135,14 +142,14 @@ export class WrapperProcess {
private
started
?:
Promise
<
void
>
private
started
?:
Promise
<
void
>
public
constructor
(
private
currentVersion
:
string
,
private
readonly
options
?:
WrapperOptions
)
{
public
constructor
(
private
currentVersion
:
string
,
private
readonly
options
?:
WrapperOptions
)
{
ipcMain
.
onDispose
(()
=>
{
ipcMain
()
.
onDispose
(()
=>
{
if
(
this
.
process
)
{
if
(
this
.
process
)
{
this
.
process
.
removeAllListeners
()
this
.
process
.
removeAllListeners
()
this
.
process
.
kill
()
this
.
process
.
kill
()
}
}
})
})
ipcMain
.
onMessage
(
async
(
message
)
=>
{
ipcMain
()
.
onMessage
(
async
(
message
)
=>
{
switch
(
message
.
type
)
{
switch
(
message
.
type
)
{
case
"
relaunch
"
:
case
"
relaunch
"
:
logger
.
info
(
`Relaunching:
${
this
.
currentVersion
}
->
${
message
.
version
}
`
)
logger
.
info
(
`Relaunching:
${
this
.
currentVersion
}
->
${
message
.
version
}
`
)
...
@@ -156,7 +163,7 @@ export class WrapperProcess {
...
@@ -156,7 +163,7 @@ export class WrapperProcess {
await
this
.
start
()
await
this
.
start
()
}
catch
(
error
)
{
}
catch
(
error
)
{
logger
.
error
(
error
.
message
)
logger
.
error
(
error
.
message
)
exit
(
typeof
error
.
code
===
"
number
"
?
error
.
code
:
1
)
ipcMain
().
exit
(
typeof
error
.
code
===
"
number
"
?
error
.
code
:
1
)
}
}
break
break
default
:
default
:
...
@@ -170,12 +177,14 @@ export class WrapperProcess {
...
@@ -170,12 +177,14 @@ export class WrapperProcess {
if
(
!
this
.
started
)
{
if
(
!
this
.
started
)
{
const
child
=
this
.
spawn
()
const
child
=
this
.
spawn
()
logger
.
debug
(
`spawned inner process
${
child
.
pid
}
`
)
logger
.
debug
(
`spawned inner process
${
child
.
pid
}
`
)
this
.
started
=
ipcMain
.
handshake
(
child
).
then
(()
=>
{
this
.
started
=
ipcMain
()
child
.
once
(
"
exit
"
,
(
code
)
=>
{
.
handshake
(
child
)
logger
.
debug
(
`inner process
${
child
.
pid
}
exited unexpectedly`
)
.
then
(()
=>
{
exit
(
code
||
0
)
child
.
once
(
"
exit
"
,
(
code
)
=>
{
logger
.
debug
(
`inner process
${
child
.
pid
}
exited unexpectedly`
)
ipcMain
().
exit
(
code
||
0
)
})
})
})
})
this
.
process
=
child
this
.
process
=
child
}
}
return
this
.
started
return
this
.
started
...
@@ -201,23 +210,23 @@ export class WrapperProcess {
...
@@ -201,23 +210,23 @@ export class WrapperProcess {
// // It's possible that the pipe has closed (for example if you run code-server
// // It's possible that the pipe has closed (for example if you run code-server
// // --version | head -1). Assume that means we're done.
// // --version | head -1). Assume that means we're done.
if
(
!
process
.
stdout
.
isTTY
)
{
if
(
!
process
.
stdout
.
isTTY
)
{
process
.
stdout
.
on
(
"
error
"
,
()
=>
exit
())
process
.
stdout
.
on
(
"
error
"
,
()
=>
ipcMain
().
exit
())
}
}
export
const
wrap
=
(
fn
:
()
=>
Promise
<
void
>
):
void
=>
{
export
const
wrap
=
(
fn
:
()
=>
Promise
<
void
>
):
void
=>
{
if
(
ipcMain
.
parentPid
)
{
if
(
ipcMain
()
.
parentPid
)
{
ipcMain
ipcMain
()
.
handshake
()
.
handshake
()
.
then
(()
=>
fn
())
.
then
(()
=>
fn
())
.
catch
((
error
:
ProcessError
):
void
=>
{
.
catch
((
error
:
ProcessError
):
void
=>
{
logger
.
error
(
error
.
message
)
logger
.
error
(
error
.
message
)
exit
(
typeof
error
.
code
===
"
number
"
?
error
.
code
:
1
)
ipcMain
().
exit
(
typeof
error
.
code
===
"
number
"
?
error
.
code
:
1
)
})
})
}
else
{
}
else
{
const
wrapper
=
new
WrapperProcess
(
require
(
"
../../package.json
"
).
version
)
const
wrapper
=
new
WrapperProcess
(
require
(
"
../../package.json
"
).
version
)
wrapper
.
start
().
catch
((
error
)
=>
{
wrapper
.
start
().
catch
((
error
)
=>
{
logger
.
error
(
error
.
message
)
logger
.
error
(
error
.
message
)
exit
(
typeof
error
.
code
===
"
number
"
?
error
.
code
:
1
)
ipcMain
().
exit
(
typeof
error
.
code
===
"
number
"
?
error
.
code
:
1
)
})
})
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录