Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
myhjmzy
code-server
提交
630ccfca
C
code-server
项目概览
myhjmzy
/
code-server
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
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 搜索 >>
提交
630ccfca
编写于
4月 17, 2019
作者:
A
Asher
提交者:
Kyle Carberry
4月 17, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add flag to install an extension from the command line (#504)
上级
c4c26058
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
53 addition
and
12 deletion
+53
-12
packages/server/src/cli.ts
packages/server/src/cli.ts
+29
-6
packages/server/src/vscode/bootstrapFork.ts
packages/server/src/vscode/bootstrapFork.ts
+12
-4
packages/vscode/src/fill/environmentService.ts
packages/vscode/src/fill/environmentService.ts
+3
-1
packages/vscode/webpack.bootstrap.config.js
packages/vscode/webpack.bootstrap.config.js
+1
-1
scripts/vscode.patch
scripts/vscode.patch
+8
-0
未找到文件。
packages/server/src/cli.ts
浏览文件 @
630ccfca
import
{
field
,
logger
}
from
"
@coder/logger
"
;
import
{
ServerMessage
,
SharedProcessActive
}
from
"
@coder/protocol/src/proto
"
;
import
{
ChildProcess
,
fork
,
ForkOptions
,
spawn
}
from
"
child_process
"
;
import
{
ChildProcess
,
fork
,
ForkOptions
}
from
"
child_process
"
;
import
{
randomFillSync
}
from
"
crypto
"
;
import
*
as
fs
from
"
fs
"
;
import
*
as
fse
from
"
fs-extra
"
;
...
...
@@ -29,6 +29,7 @@ commander.version(process.env.VERSION || "development")
.
option
(
"
-N, --no-auth
"
,
"
Start without requiring authentication.
"
,
undefined
)
.
option
(
"
-H, --allow-http
"
,
"
Allow http connections.
"
,
false
)
.
option
(
"
-P, --password <value>
"
,
"
Specify a password for authentication.
"
)
.
option
(
"
--install-extension <value>
"
,
"
Install an extension by its ID.
"
)
.
option
(
"
--bootstrap-fork <name>
"
,
"
Used for development. Never set.
"
)
.
option
(
"
--extra-args <args>
"
,
"
Used for development. Never set.
"
)
.
arguments
(
"
Specify working directory.
"
)
...
...
@@ -61,6 +62,8 @@ const bold = (text: string | number): string | number => {
readonly
cert
?:
string
;
readonly
certKey
?:
string
;
readonly
installExtension
?:
string
;
readonly
bootstrapFork
?:
string
;
readonly
extraArgs
?:
string
;
};
...
...
@@ -112,11 +115,11 @@ const bold = (text: string | number): string | number => {
process
.
exit
(
1
);
}
((
options
.
extraArgs
?
JSON
.
parse
(
options
.
extraArgs
)
:
[])
as
string
[]).
forEach
((
arg
,
i
)
=>
{
// [0] contains the binary running the script (`node` for example) and
// [1] contains the script name, so the arguments come after that.
process
.
argv
[
i
+
2
]
=
arg
;
})
;
process
.
argv
=
[
process
.
argv
[
0
],
process
.
argv
[
1
],
...(
options
.
extraArgs
?
JSON
.
parse
(
options
.
extraArgs
)
:
[]),
]
;
return
requireModule
(
modulePath
,
builtInExtensionsDir
);
}
...
...
@@ -162,6 +165,26 @@ const bold = (text: string | number): string | number => {
logger
.
warn
(
'
"--data-dir" is deprecated. Use "--user-data-dir" instead.
'
);
}
if
(
options
.
installExtension
)
{
const
fork
=
forkModule
(
"
vs/code/node/cli
"
,
[
"
--user-data-dir
"
,
dataDir
,
"
--builtin-extensions-dir
"
,
builtInExtensionsDir
,
"
--extensions-dir
"
,
extensionsDir
,
"
--install-extension
"
,
options
.
installExtension
,
],
{
env
:
{
VSCODE_ALLOW_IO
:
"
true
"
,
VSCODE_LOGS
:
process
.
env
.
VSCODE_LOGS
,
},
},
dataDir
);
fork
.
stdout
.
on
(
"
data
"
,
(
d
:
Buffer
)
=>
d
.
toString
().
split
(
"
\n
"
).
forEach
((
l
)
=>
logger
.
info
(
l
)));
fork
.
stderr
.
on
(
"
data
"
,
(
d
:
Buffer
)
=>
d
.
toString
().
split
(
"
\n
"
).
forEach
((
l
)
=>
logger
.
error
(
l
)));
fork
.
on
(
"
exit
"
,
()
=>
process
.
exit
());
return
;
}
// TODO: fill in appropriate doc url
logger
.
info
(
"
Additional documentation: http://github.com/codercom/code-server
"
);
logger
.
info
(
"
Initializing
"
,
field
(
"
data-dir
"
,
dataDir
),
field
(
"
extensions-dir
"
,
extensionsDir
),
field
(
"
working-dir
"
,
workingDir
),
field
(
"
log-dir
"
,
logDir
));
...
...
packages/server/src/vscode/bootstrapFork.ts
浏览文件 @
630ccfca
...
...
@@ -82,7 +82,6 @@ export const requireModule = (modulePath: string, builtInExtensionsDir: string):
* @param modulePath Path of the VS Code module to load.
*/
export
const
forkModule
=
(
modulePath
:
string
,
args
?:
string
[],
options
?:
cp
.
ForkOptions
,
dataDir
?:
string
):
cp
.
ChildProcess
=>
{
let
proc
:
cp
.
ChildProcess
;
const
forkOptions
:
cp
.
ForkOptions
=
{
stdio
:
[
null
,
null
,
null
,
"
ipc
"
],
};
...
...
@@ -91,18 +90,27 @@ export const forkModule = (modulePath: string, args?: string[], options?: cp.For
delete
options
.
env
.
ELECTRON_RUN_AS_NODE
;
forkOptions
.
env
=
options
.
env
;
}
const
forkArgs
=
[
"
--bootstrap-fork
"
,
modulePath
];
if
(
args
)
{
forkArgs
.
push
(
"
--extra-args
"
,
JSON
.
stringify
(
args
));
}
if
(
dataDir
)
{
forkArgs
.
push
(
"
--data-dir
"
,
dataDir
);
forkArgs
.
push
(
"
--
user-
data-dir
"
,
dataDir
);
}
const
nodeArgs
=
[];
if
(
isCli
)
{
proc
=
cp
.
spawn
(
process
.
execPath
,
[
path
.
join
(
buildDir
,
"
out
"
,
"
cli.js
"
),
...
forkArgs
],
forkOptions
);
nodeArgs
.
push
(
path
.
join
(
buildDir
,
"
out
"
,
"
cli.js
"
)
);
}
else
{
proc
=
cp
.
spawn
(
process
.
execPath
,
[
"
--require
"
,
"
ts-node/register
"
,
"
--require
"
,
"
tsconfig-paths/register
"
,
process
.
argv
[
1
],
...
forkArgs
],
forkOptions
);
nodeArgs
.
push
(
"
--require
"
,
"
ts-node/register
"
,
"
--require
"
,
"
tsconfig-paths/register
"
,
process
.
argv
[
1
],
);
}
const
proc
=
cp
.
spawn
(
process
.
execPath
,
[...
nodeArgs
,
...
forkArgs
],
forkOptions
);
if
(
args
&&
args
[
0
]
===
"
--type=watcherService
"
&&
os
.
platform
()
===
"
linux
"
)
{
cp
.
exec
(
`renice -n 19 -p
${
proc
.
pid
}
`
,
(
error
)
=>
{
if
(
error
)
{
...
...
packages/vscode/src/fill/environmentService.ts
浏览文件 @
630ccfca
import
*
as
path
from
"
path
"
;
import
*
as
paths
from
"
./paths
"
;
import
*
as
environment
from
"
vs/platform/environment/node/environmentService
"
;
/**
* Customize paths using data received from the initialization message.
*/
export
class
EnvironmentService
extends
environment
.
EnvironmentService
{
public
get
sharedIPCHandle
():
string
{
return
paths
.
getSocketPath
()
||
super
.
sharedIPCHandle
;
...
...
packages/vscode/webpack.bootstrap.config.js
浏览文件 @
630ccfca
...
...
@@ -60,7 +60,7 @@ module.exports = merge(
"
native-keymap
"
:
path
.
join
(
vsFills
,
"
native-keymap.ts
"
),
"
native-watchdog
"
:
path
.
join
(
vsFills
,
"
native-watchdog.ts
"
),
"
vs/base/common/amd
"
:
path
.
resolve
(
vsFills
,
"
amd.ts
"
),
"
vs/base/node/paths
"
:
path
.
resolve
(
vsFills
,
"
paths.ts
"
),
"
vs/base/node/paths
"
:
path
.
join
(
vsFills
,
"
paths.ts
"
),
"
vs/platform/product/node/package
"
:
path
.
resolve
(
vsFills
,
"
package.ts
"
),
"
vs/platform/product/node/product
"
:
path
.
resolve
(
vsFills
,
"
product.ts
"
),
"
vs/base/node/zip
"
:
path
.
resolve
(
vsFills
,
"
zip.ts
"
),
...
...
scripts/vscode.patch
浏览文件 @
630ccfca
...
...
@@ -158,6 +158,14 @@ index 6fd8249..04c0933 100644
+ backupMainService.initialize().catch(console.error);
@@ -223,0 +236 @@
async function handshake(configuration: ISharedProcessConfiguration): Promise<vo
+startup({ machineId: "1" });
diff --git a/src/vs/code/node/cli.ts b/src/vs/code/node/cli.ts
index 1f8b17a..2a875f9 100644
--- a/src/vs/code/node/cli.ts
+++ b/src/vs/code/node/cli.ts
@@ -43,0 +44,3 @@
export async function main(argv: string[]): Promise<any> {
+ const cli = await new Promise<IMainCli>((c, e) => require(['vs/code/node/cliProcessMain'], c, e));
+ await cli.main(args);
+ return; // Always just do this for now.
diff --git a/src/vs/editor/browser/config/configuration.ts b/src/vs/editor/browser/config/configuration.ts
index f97a692..0206957 100644
--- a/src/vs/editor/browser/config/configuration.ts
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录