Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
deno
提交
f6a9d7d7
D
deno
项目概览
张重言
/
deno
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
deno
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f6a9d7d7
编写于
5月 03, 2019
作者:
B
Bartek Iwańczuk
提交者:
Ryan Dahl
5月 03, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add "deno run" subcommand (#2215)
上级
36081171
变更
54
隐藏空白更改
内联
并排
Showing
54 changed file
with
314 addition
and
210 deletion
+314
-210
cli/flags.rs
cli/flags.rs
+239
-132
cli/main.rs
cli/main.rs
+1
-0
tests/001_hello.test
tests/001_hello.test
+1
-1
tests/002_hello.test
tests/002_hello.test
+1
-1
tests/003_relative_import.test
tests/003_relative_import.test
+1
-1
tests/004_set_timeout.test
tests/004_set_timeout.test
+1
-1
tests/005_more_imports.test
tests/005_more_imports.test
+1
-1
tests/006_url_imports.test
tests/006_url_imports.test
+1
-1
tests/012_async.test
tests/012_async.test
+1
-1
tests/016_double_await.test
tests/016_double_await.test
+1
-1
tests/017_import_redirect.test
tests/017_import_redirect.test
+1
-1
tests/018_async_catch.test
tests/018_async_catch.test
+1
-1
tests/019_media_types.test
tests/019_media_types.test
+1
-1
tests/020_json_modules.test
tests/020_json_modules.test
+1
-1
tests/021_mjs_modules.test
tests/021_mjs_modules.test
+1
-1
tests/023_no_ext_with_headers.test
tests/023_no_ext_with_headers.test
+1
-1
tests/024_import_no_ext_with_headers.test
tests/024_import_no_ext_with_headers.test
+1
-1
tests/025_high_precision.test
tests/025_high_precision.test
+1
-1
tests/025_reload_js_type_error.test
tests/025_reload_js_type_error.test
+1
-1
tests/026_redirect_javascript.js.test
tests/026_redirect_javascript.js.test
+1
-1
tests/026_workers.test
tests/026_workers.test
+1
-1
tests/027_redirect_typescript.ts.test
tests/027_redirect_typescript.ts.test
+1
-1
tests/028_args.test
tests/028_args.test
+1
-1
tests/async_error.test
tests/async_error.test
+1
-1
tests/circular1.test
tests/circular1.test
+1
-1
tests/config.test
tests/config.test
+1
-1
tests/error_001.test
tests/error_001.test
+1
-1
tests/error_002.test
tests/error_002.test
+1
-1
tests/error_003_typescript.test
tests/error_003_typescript.test
+1
-1
tests/error_004_missing_module.test
tests/error_004_missing_module.test
+1
-1
tests/error_005_missing_dynamic_import.test
tests/error_005_missing_dynamic_import.test
+1
-1
tests/error_006_import_ext_failure.test
tests/error_006_import_ext_failure.test
+1
-1
tests/error_007_any.test
tests/error_007_any.test
+1
-1
tests/error_008_checkjs.test
tests/error_008_checkjs.test
+1
-1
tests/error_syntax.test
tests/error_syntax.test
+1
-1
tests/exit_error42.test
tests/exit_error42.test
+1
-1
tests/https_import.test
tests/https_import.test
+1
-1
tests/if_main.test
tests/if_main.test
+1
-1
tests/import_meta.test
tests/import_meta.test
+1
-1
tests/unbuffered_stderr.test
tests/unbuffered_stderr.test
+1
-1
tests/unbuffered_stdout.test
tests/unbuffered_stdout.test
+1
-1
tests/v8_flags.test
tests/v8_flags.test
+1
-1
tests/wasm.test
tests/wasm.test
+2
-2
tools/benchmark.py
tools/benchmark.py
+4
-3
tools/deno_dir_test.py
tools/deno_dir_test.py
+1
-1
tools/http_benchmark.py
tools/http_benchmark.py
+2
-2
tools/is_tty_test.py
tools/is_tty_test.py
+1
-1
tools/permission_prompt_test.py
tools/permission_prompt_test.py
+2
-1
tools/repl_test.py
tools/repl_test.py
+1
-1
tools/test.py
tools/test.py
+3
-3
tools/throughput_benchmark.py
tools/throughput_benchmark.py
+3
-2
tools/unit_tests.py
tools/unit_tests.py
+1
-1
website/index.html
website/index.html
+1
-1
website/manual.md
website/manual.md
+13
-20
未找到文件。
cli/flags.rs
浏览文件 @
f6a9d7d7
...
...
@@ -36,75 +36,41 @@ pub fn create_cli_app<'a, 'b>() -> App<'a, 'b> {
App
::
new
(
"deno"
)
.bin_name
(
"deno"
)
.global_settings
(
&
[
AppSettings
::
ColorNever
])
.settings
(
&
[
AppSettings
::
AllowExternalSubcommands
,
AppSettings
::
DisableVersion
,
])
.after_help
(
ENV_VARIABLES_HELP
)
.settings
(
&
[
AppSettings
::
DisableVersion
])
.after_help
(
ENV_VARIABLES_HELP
)
.arg
(
Arg
::
with_name
(
"allow-read"
)
.long
(
"allow-read"
)
.help
(
"Allow file system read access"
),
)
.arg
(
Arg
::
with_name
(
"allow-write"
)
.long
(
"allow-write"
)
.help
(
"Allow file system write access"
),
)
.arg
(
Arg
::
with_name
(
"allow-net"
)
.long
(
"allow-net"
)
.help
(
"Allow network access"
),
)
.arg
(
Arg
::
with_name
(
"allow-env"
)
.long
(
"allow-env"
)
.help
(
"Allow environment access"
),
)
.arg
(
Arg
::
with_name
(
"allow-run"
)
.long
(
"allow-run"
)
.help
(
"Allow running subprocesses"
),
)
.arg
(
Arg
::
with_name
(
"allow-high-precision"
)
.long
(
"allow-high-precision"
)
.help
(
"Allow high precision time measurement"
),
)
.arg
(
Arg
::
with_name
(
"allow-all"
)
.short
(
"A"
)
.long
(
"allow-all"
)
.help
(
"Allow all permissions"
),
)
.arg
(
Arg
::
with_name
(
"no-prompt"
)
.long
(
"no-prompt"
)
.help
(
"Do not use prompts"
),
)
.arg
(
Arg
::
with_name
(
"no-fetch"
)
.long
(
"no-fetch"
)
.help
(
"Do not download remote modules"
),
)
.arg
(
Arg
::
with_name
(
"log-debug"
)
.short
(
"D"
)
.long
(
"log-debug"
)
.help
(
"Log debug output"
),
.help
(
"Log debug output"
)
.global
(
true
),
)
.arg
(
Arg
::
with_name
(
"reload"
)
.short
(
"r"
)
.long
(
"reload"
)
.help
(
"Reload source code cache (recompile TypeScript)"
),
.help
(
"Reload source code cache (recompile TypeScript)"
)
.global
(
true
),
)
.arg
(
Arg
::
with_name
(
"config"
)
.short
(
"c"
)
.long
(
"config"
)
.value_name
(
"FILE"
)
.help
(
"Load compiler configuration file"
)
.takes_value
(
true
),
.takes_value
(
true
)
.global
(
true
),
)
.arg
(
Arg
::
with_name
(
"v8-options"
)
.long
(
"v8-options"
)
.help
(
"Print V8 command line options"
),
.help
(
"Print V8 command line options"
)
.global
(
true
),
)
.arg
(
Arg
::
with_name
(
"v8-flags"
)
.long
(
"v8-flags"
)
.takes_value
(
true
)
.use_delimiter
(
true
)
.require_equals
(
true
)
.help
(
"Set V8 command line options"
),
.help
(
"Set V8 command line options"
)
.global
(
true
),
)
.subcommand
(
SubCommand
::
with_name
(
"version"
)
.setting
(
AppSettings
::
DisableVersion
)
...
...
@@ -196,7 +162,69 @@ Prettier dependencies on first run.
.required
(
true
),
),
)
.subcommand
(
SubCommand
::
with_name
(
"xeval"
)
SubCommand
::
with_name
(
"run"
)
.settings
(
&
[
AppSettings
::
AllowExternalSubcommands
,
AppSettings
::
DisableHelpSubcommand
,
AppSettings
::
DisableVersion
,
AppSettings
::
SubcommandRequired
,
])
.about
(
"Run a program given a filename or url to the source code"
)
.long_about
(
"
Run a program given a filename or url to the source code.
By default all programs are run in sandbox without access to disk, network or
ability to spawn subprocesses.
deno run https://deno.land/welcome.ts
# run program with permission to read from disk and listen to network
deno run --allow-net --allow-read https://deno.land/std/http/file_server.ts
# run program with all permissions
deno run -A https://deno.land/std/http/file_server.ts
"
,
)
.arg
(
Arg
::
with_name
(
"allow-read"
)
.long
(
"allow-read"
)
.help
(
"Allow file system read access"
),
)
.arg
(
Arg
::
with_name
(
"allow-write"
)
.long
(
"allow-write"
)
.help
(
"Allow file system write access"
),
)
.arg
(
Arg
::
with_name
(
"allow-net"
)
.long
(
"allow-net"
)
.help
(
"Allow network access"
),
)
.arg
(
Arg
::
with_name
(
"allow-env"
)
.long
(
"allow-env"
)
.help
(
"Allow environment access"
),
)
.arg
(
Arg
::
with_name
(
"allow-run"
)
.long
(
"allow-run"
)
.help
(
"Allow running subprocesses"
),
)
.arg
(
Arg
::
with_name
(
"allow-high-precision"
)
.long
(
"allow-high-precision"
)
.help
(
"Allow high precision time measurement"
),
)
.arg
(
Arg
::
with_name
(
"allow-all"
)
.short
(
"A"
)
.long
(
"allow-all"
)
.help
(
"Allow all permissions"
),
)
.arg
(
Arg
::
with_name
(
"no-prompt"
)
.long
(
"no-prompt"
)
.help
(
"Do not use prompts"
),
)
.subcommand
(
// this is a fake subcommand - it's used in conjunction with
// AppSettings:AllowExternalSubcommand to treat it as an
// entry point script
SubCommand
::
with_name
(
"<script>"
)
.about
(
"Script to run"
),
),
)
.subcommand
(
SubCommand
::
with_name
(
"xeval"
)
.setting
(
AppSettings
::
DisableVersion
)
.about
(
"Eval a script on text segments from stdin"
)
.long_about
(
...
...
@@ -226,14 +254,8 @@ Otherwise '$' will be used as default variable name.
.help
(
"Set delimiter, defaults to newline"
)
.takes_value
(
true
),
)
.arg
(
Arg
::
with_name
(
"code"
)
.takes_value
(
true
)
.required
(
true
)),
)
.subcommand
(
// this is a fake subcommand - it's used in conjunction with
// AppSettings:AllowExternalSubcommand to treat it as an
// entry point script
SubCommand
::
with_name
(
"<script>"
)
.about
(
"Script to run"
),
)
}
/// Parse ArgMatches into internal DenoFlags structure.
/// This method should not make any side effects.
#[cfg_attr(feature
=
"cargo-clippy"
,
allow(stutter))]
...
...
@@ -250,39 +272,6 @@ pub fn parse_flags(matches: ArgMatches) -> DenoFlags {
flags
.reload
=
true
;
}
flags
.config_path
=
matches
.value_of
(
"config"
)
.map
(
ToOwned
::
to_owned
);
if
matches
.is_present
(
"allow-read"
)
{
flags
.allow_read
=
true
;
}
if
matches
.is_present
(
"allow-write"
)
{
flags
.allow_write
=
true
;
}
if
matches
.is_present
(
"allow-net"
)
{
flags
.allow_net
=
true
;
}
if
matches
.is_present
(
"allow-env"
)
{
flags
.allow_env
=
true
;
}
if
matches
.is_present
(
"allow-run"
)
{
flags
.allow_run
=
true
;
}
if
matches
.is_present
(
"allow-high-precision"
)
{
flags
.allow_high_precision
=
true
;
}
if
matches
.is_present
(
"allow-all"
)
{
flags
.allow_read
=
true
;
flags
.allow_env
=
true
;
flags
.allow_net
=
true
;
flags
.allow_run
=
true
;
flags
.allow_read
=
true
;
flags
.allow_write
=
true
;
flags
.allow_high_precision
=
true
;
}
if
matches
.is_present
(
"no-prompt"
)
{
flags
.no_prompts
=
true
;
}
if
matches
.is_present
(
"no-fetch"
)
{
flags
.no_fetch
=
true
;
}
if
matches
.is_present
(
"v8-options"
)
{
let
v8_flags
=
svec!
[
"deno"
,
"--help"
];
flags
.v8_flags
=
Some
(
v8_flags
);
...
...
@@ -298,6 +287,40 @@ pub fn parse_flags(matches: ArgMatches) -> DenoFlags {
flags
.v8_flags
=
Some
(
v8_flags
);
}
// flags specific to "run" subcommand
if
let
Some
(
run_matches
)
=
matches
.subcommand_matches
(
"run"
)
{
if
run_matches
.is_present
(
"allow-read"
)
{
flags
.allow_read
=
true
;
}
if
run_matches
.is_present
(
"allow-write"
)
{
flags
.allow_write
=
true
;
}
if
run_matches
.is_present
(
"allow-net"
)
{
flags
.allow_net
=
true
;
}
if
run_matches
.is_present
(
"allow-env"
)
{
flags
.allow_env
=
true
;
}
if
run_matches
.is_present
(
"allow-run"
)
{
flags
.allow_run
=
true
;
}
if
run_matches
.is_present
(
"allow-high-precision"
)
{
flags
.allow_high_precision
=
true
;
}
if
run_matches
.is_present
(
"allow-all"
)
{
flags
.allow_read
=
true
;
flags
.allow_env
=
true
;
flags
.allow_net
=
true
;
flags
.allow_run
=
true
;
flags
.allow_read
=
true
;
flags
.allow_write
=
true
;
flags
.allow_high_precision
=
true
;
}
if
run_matches
.is_present
(
"no-prompt"
)
{
flags
.no_prompts
=
true
;
}
}
flags
}
...
...
@@ -314,6 +337,7 @@ pub enum DenoSubcommand {
Repl
,
Run
,
Types
,
Version
,
Xeval
,
}
...
...
@@ -327,6 +351,12 @@ pub fn flags_from_vec(
let
subcommand
=
match
matches
.subcommand
()
{
(
"eval"
,
Some
(
eval_match
))
=>
{
flags
.allow_net
=
true
;
flags
.allow_env
=
true
;
flags
.allow_run
=
true
;
flags
.allow_read
=
true
;
flags
.allow_write
=
true
;
flags
.allow_high_precision
=
true
;
let
code
:
&
str
=
eval_match
.value_of
(
"code"
)
.unwrap
();
argv
.extend
(
vec!
[
code
.to_string
()]);
DenoSubcommand
::
Eval
...
...
@@ -356,6 +386,25 @@ pub fn flags_from_vec(
DenoSubcommand
::
Info
}
(
"types"
,
Some
(
_
))
=>
DenoSubcommand
::
Types
,
(
"run"
,
Some
(
run_match
))
=>
{
match
run_match
.subcommand
()
{
(
script
,
Some
(
script_match
))
=>
{
argv
.extend
(
vec!
[
script
.to_string
()]);
// check if there are any extra arguments that should
// be passed to script
if
script_match
.is_present
(
""
)
{
let
script_args
:
Vec
<
String
>
=
script_match
.values_of
(
""
)
.unwrap
()
.map
(
String
::
from
)
.collect
();
argv
.extend
(
script_args
);
}
DenoSubcommand
::
Run
}
_
=>
unreachable!
(),
}
}
(
"xeval"
,
Some
(
eval_match
))
=>
{
let
code
:
&
str
=
eval_match
.value_of
(
"code"
)
.unwrap
();
flags
.xeval_replvar
=
...
...
@@ -367,21 +416,16 @@ pub fn flags_from_vec(
argv
.extend
(
vec!
[
code
.to_string
()]);
DenoSubcommand
::
Xeval
}
(
script
,
Some
(
script_match
))
=>
{
argv
.extend
(
vec!
[
script
.to_string
()]);
// check if there are any extra arguments that should
// be passed to script
if
script_match
.is_present
(
""
)
{
let
script_args
:
Vec
<
String
>
=
script_match
.values_of
(
""
)
.unwrap
()
.map
(
String
::
from
)
.collect
();
argv
.extend
(
script_args
);
}
DenoSubcommand
::
Run
(
"version"
,
Some
(
_
))
=>
DenoSubcommand
::
Version
,
_
=>
{
flags
.allow_net
=
true
;
flags
.allow_env
=
true
;
flags
.allow_run
=
true
;
flags
.allow_read
=
true
;
flags
.allow_write
=
true
;
flags
.allow_high_precision
=
true
;
DenoSubcommand
::
Repl
}
_
=>
DenoSubcommand
::
Repl
,
};
(
flags
,
subcommand
,
argv
)
...
...
@@ -401,14 +445,14 @@ mod tests {
..
DenoFlags
::
default
()
}
);
assert_eq!
(
subcommand
,
DenoSubcommand
::
Ru
n
);
assert_eq!
(
argv
,
svec!
[
"deno"
,
"version"
]);
assert_eq!
(
subcommand
,
DenoSubcommand
::
Versio
n
);
assert_eq!
(
argv
,
svec!
[
"deno"
]);
}
#[test]
fn
test_flags_from_vec_2
()
{
let
(
flags
,
subcommand
,
argv
)
=
flags_from_vec
(
svec!
[
"deno"
,
"-r"
,
"-D"
,
"script.ts"
]);
flags_from_vec
(
svec!
[
"deno"
,
"-r"
,
"-D"
,
"
run"
,
"
script.ts"
]);
assert_eq!
(
flags
,
DenoFlags
{
...
...
@@ -423,12 +467,19 @@ mod tests {
#[test]
fn
test_flags_from_vec_3
()
{
let
(
flags
,
subcommand
,
argv
)
=
flags_from_vec
(
svec!
[
"deno"
,
"-r"
,
"--allow-write"
,
"script.ts"
]);
let
(
flags
,
subcommand
,
argv
)
=
flags_from_vec
(
svec!
[
"deno"
,
"run"
,
"-r"
,
"-D"
,
"--allow-write"
,
"script.ts"
]);
assert_eq!
(
flags
,
DenoFlags
{
reload
:
true
,
log_debug
:
true
,
allow_write
:
true
,
..
DenoFlags
::
default
()
}
...
...
@@ -440,7 +491,7 @@ mod tests {
#[test]
fn
test_flags_from_vec_4
()
{
let
(
flags
,
subcommand
,
argv
)
=
flags_from_vec
(
svec!
[
"deno"
,
"-Dr"
,
"--allow-write"
,
"script.ts"
]);
flags_from_vec
(
svec!
[
"deno"
,
"-Dr"
,
"
run"
,
"
--allow-write"
,
"script.ts"
]);
assert_eq!
(
flags
,
DenoFlags
{
...
...
@@ -457,7 +508,7 @@ mod tests {
#[test]
fn
test_flags_from_vec_5
()
{
let
(
flags
,
subcommand
,
argv
)
=
flags_from_vec
(
svec!
[
"deno"
,
"--v8-options"
]);
flags_from_vec
(
svec!
[
"deno"
,
"--v8-options"
,
"run"
,
"script.ts"
]);
assert_eq!
(
flags
,
DenoFlags
{
...
...
@@ -465,11 +516,15 @@ mod tests {
..
DenoFlags
::
default
()
}
);
assert_eq!
(
subcommand
,
DenoSubcommand
::
R
epl
);
assert_eq!
(
argv
,
svec!
[
"deno"
]);
assert_eq!
(
subcommand
,
DenoSubcommand
::
R
un
);
assert_eq!
(
argv
,
svec!
[
"deno"
,
"script.ts"
]);
let
(
flags
,
subcommand
,
argv
)
=
flags_from_vec
(
svec!
[
"deno"
,
"--v8-flags=--expose-gc,--gc-stats=1"
]);
let
(
flags
,
subcommand
,
argv
)
=
flags_from_vec
(
svec!
[
"deno"
,
"--v8-flags=--expose-gc,--gc-stats=1"
,
"run"
,
"script.ts"
]);
assert_eq!
(
flags
,
DenoFlags
{
...
...
@@ -477,14 +532,20 @@ mod tests {
..
DenoFlags
::
default
()
}
);
assert_eq!
(
subcommand
,
DenoSubcommand
::
R
epl
);
assert_eq!
(
argv
,
svec!
[
"deno"
]);
assert_eq!
(
subcommand
,
DenoSubcommand
::
R
un
);
assert_eq!
(
argv
,
svec!
[
"deno"
,
"script.ts"
]);
}
#[test]
fn
test_flags_from_vec_6
()
{
let
(
flags
,
subcommand
,
argv
)
=
flags_from_vec
(
svec!
[
"deno"
,
"--allow-net"
,
"gist.ts"
,
"--title"
,
"X"
]);
let
(
flags
,
subcommand
,
argv
)
=
flags_from_vec
(
svec!
[
"deno"
,
"run"
,
"--allow-net"
,
"gist.ts"
,
"--title"
,
"X"
]);
assert_eq!
(
flags
,
DenoFlags
{
...
...
@@ -499,7 +560,7 @@ mod tests {
#[test]
fn
test_flags_from_vec_7
()
{
let
(
flags
,
subcommand
,
argv
)
=
flags_from_vec
(
svec!
[
"deno"
,
"--allow-all"
,
"gist.ts"
]);
flags_from_vec
(
svec!
[
"deno"
,
"
run"
,
"
--allow-all"
,
"gist.ts"
]);
assert_eq!
(
flags
,
DenoFlags
{
...
...
@@ -519,7 +580,7 @@ mod tests {
#[test]
fn
test_flags_from_vec_8
()
{
let
(
flags
,
subcommand
,
argv
)
=
flags_from_vec
(
svec!
[
"deno"
,
"--allow-read"
,
"gist.ts"
]);
flags_from_vec
(
svec!
[
"deno"
,
"
run"
,
"
--allow-read"
,
"gist.ts"
]);
assert_eq!
(
flags
,
DenoFlags
{
...
...
@@ -533,8 +594,12 @@ mod tests {
#[test]
fn
test_flags_from_vec_9
()
{
let
(
flags
,
subcommand
,
argv
)
=
flags_from_vec
(
svec!
[
"deno"
,
"--allow-high-precision"
,
"script.ts"
]);
let
(
flags
,
subcommand
,
argv
)
=
flags_from_vec
(
svec!
[
"deno"
,
"run"
,
"--allow-high-precision"
,
"script.ts"
]);
assert_eq!
(
flags
,
DenoFlags
{
...
...
@@ -553,6 +618,7 @@ mod tests {
// script args as Deno.args
let
(
flags
,
subcommand
,
argv
)
=
flags_from_vec
(
svec!
[
"deno"
,
"run"
,
"--allow-write"
,
"script.ts"
,
"-D"
,
...
...
@@ -616,6 +682,60 @@ mod tests {
#[test]
fn
test_flags_from_vec_15
()
{
let
(
flags
,
subcommand
,
argv
)
=
flags_from_vec
(
svec!
[
"deno"
,
"run"
,
"-c"
,
"tsconfig.json"
,
"script.ts"
]);
assert_eq!
(
flags
,
DenoFlags
{
config_path
:
Some
(
"tsconfig.json"
.to_owned
()),
..
DenoFlags
::
default
()
}
);
assert_eq!
(
subcommand
,
DenoSubcommand
::
Run
);
assert_eq!
(
argv
,
svec!
[
"deno"
,
"script.ts"
]);
}
#[test]
fn
test_flags_from_vec_16
()
{
let
(
flags
,
subcommand
,
argv
)
=
flags_from_vec
(
svec!
[
"deno"
,
"eval"
,
"'console.log(
\"
hello
\"
)'"
]);
assert_eq!
(
flags
,
DenoFlags
{
allow_net
:
true
,
allow_env
:
true
,
allow_run
:
true
,
allow_read
:
true
,
allow_write
:
true
,
allow_high_precision
:
true
,
..
DenoFlags
::
default
()
}
);
assert_eq!
(
subcommand
,
DenoSubcommand
::
Eval
);
assert_eq!
(
argv
,
svec!
[
"deno"
,
"'console.log(
\"
hello
\"
)'"
]);
}
#[test]
fn
test_flags_from_vec_17
()
{
let
(
flags
,
subcommand
,
argv
)
=
flags_from_vec
(
svec!
[
"deno"
]);
assert_eq!
(
flags
,
DenoFlags
{
allow_net
:
true
,
allow_env
:
true
,
allow_run
:
true
,
allow_read
:
true
,
allow_write
:
true
,
allow_high_precision
:
true
,
..
DenoFlags
::
default
()
}
);
assert_eq!
(
subcommand
,
DenoSubcommand
::
Repl
);
assert_eq!
(
argv
,
svec!
[
"deno"
]);
}
#[test]
fn
test_flags_from_vec_18
()
{
let
(
flags
,
subcommand
,
argv
)
=
flags_from_vec
(
svec!
[
"deno"
,
"xeval"
,
...
...
@@ -632,17 +752,4 @@ mod tests {
assert_eq!
(
subcommand
,
DenoSubcommand
::
Xeval
);
assert_eq!
(
argv
,
svec!
[
"deno"
,
"console.log(val)"
]);
}
#[test]
fn
test_set_flags_11
()
{
let
(
flags
,
_
,
_
)
=
flags_from_vec
(
svec!
[
"deno"
,
"-c"
,
"tsconfig.json"
,
"script.ts"
]);
assert_eq!
(
flags
,
DenoFlags
{
config_path
:
Some
(
"tsconfig.json"
.to_owned
()),
..
DenoFlags
::
default
()
}
)
}
}
cli/main.rs
浏览文件 @
f6a9d7d7
...
...
@@ -300,6 +300,7 @@ fn main() {
DenoSubcommand
::
Repl
=>
run_repl
(
flags
,
argv
),
DenoSubcommand
::
Run
=>
run_script
(
flags
,
argv
),
DenoSubcommand
::
Types
=>
types_command
(),
DenoSubcommand
::
Version
=>
run_script
(
flags
,
argv
),
DenoSubcommand
::
Xeval
=>
xeval_command
(
flags
,
argv
),
}
}
tests/001_hello.test
浏览文件 @
f6a9d7d7
args
:
--
reload
tests
/
001_
hello
.
js
args
:
run
--
reload
tests
/
001_
hello
.
js
output
:
tests
/
001_
hello
.
js
.
out
tests/002_hello.test
浏览文件 @
f6a9d7d7
args
:
--
reload
tests
/
002_
hello
.
ts
args
:
run
--
reload
tests
/
002_
hello
.
ts
output
:
tests
/
002_
hello
.
ts
.
out
tests/003_relative_import.test
浏览文件 @
f6a9d7d7
args
:
--
reload
tests
/
003_
relative_import
.
ts
args
:
run
--
reload
tests
/
003_
relative_import
.
ts
output
:
tests
/
003_
relative_import
.
ts
.
out
tests/004_set_timeout.test
浏览文件 @
f6a9d7d7
args
:
--
reload
tests
/
004_
set_timeout
.
ts
args
:
run
--
reload
tests
/
004_
set_timeout
.
ts
output
:
tests
/
004_
set_timeout
.
ts
.
out
tests/005_more_imports.test
浏览文件 @
f6a9d7d7
args
:
--
reload
tests
/
005_
more_imports
.
ts
args
:
run
--
reload
tests
/
005_
more_imports
.
ts
output
:
tests
/
005_
more_imports
.
ts
.
out
tests/006_url_imports.test
浏览文件 @
f6a9d7d7
args
:
--
reload
tests
/
006_
url_imports
.
ts
args
:
run
--
reload
tests
/
006_
url_imports
.
ts
output
:
tests
/
006_
url_imports
.
ts
.
out
tests/012_async.test
浏览文件 @
f6a9d7d7
args
:
--
reload
tests
/
012_
async
.
ts
args
:
run
--
reload
tests
/
012_
async
.
ts
output
:
tests
/
012_
async
.
ts
.
out
tests/016_double_await.test
浏览文件 @
f6a9d7d7
args
:
--
allow
-
read
--
reload
tests
/
016_
double_await
.
ts
args
:
run
--
allow
-
read
--
reload
tests
/
016_
double_await
.
ts
output
:
tests
/
016_
double_await
.
ts
.
out
tests/017_import_redirect.test
浏览文件 @
f6a9d7d7
args
:
--
reload
tests
/
017_
import_redirect
.
ts
args
:
run
--
reload
tests
/
017_
import_redirect
.
ts
output
:
tests
/
017_
import_redirect
.
ts
.
out
tests/018_async_catch.test
浏览文件 @
f6a9d7d7
args
:
--
reload
tests
/
01
8_
async_catch
.
ts
args
:
run
--
reload
tests
/
01
8_
async_catch
.
ts
output
:
tests
/
01
8_
async_catch
.
ts
.
out
tests/019_media_types.test
浏览文件 @
f6a9d7d7
args
:
--
reload
tests
/
01
9_
media_types
.
ts
args
:
run
--
reload
tests
/
01
9_
media_types
.
ts
output
:
tests
/
01
9_
media_types
.
ts
.
out
tests/020_json_modules.test
浏览文件 @
f6a9d7d7
args
:
--
reload
tests
/
020_
json_modules
.
ts
args
:
run
--
reload
tests
/
020_
json_modules
.
ts
output
:
tests
/
020_
json_modules
.
ts
.
out
tests/021_mjs_modules.test
浏览文件 @
f6a9d7d7
args
:
--
reload
tests
/
021_
mjs_modules
.
ts
args
:
run
--
reload
tests
/
021_
mjs_modules
.
ts
output
:
tests
/
021_
mjs_modules
.
ts
.
out
tests/023_no_ext_with_headers.test
浏览文件 @
f6a9d7d7
args
:
--
reload
tests
/
023_
no_ext_with_headers
args
:
run
--
reload
tests
/
023_
no_ext_with_headers
output
:
tests
/
023_
no_ext_with_headers
.
out
tests/024_import_no_ext_with_headers.test
浏览文件 @
f6a9d7d7
args
:
--
reload
tests
/
024_
import_no_ext_with_headers
.
ts
args
:
run
--
reload
tests
/
024_
import_no_ext_with_headers
.
ts
output
:
tests
/
024_
import_no_ext_with_headers
.
ts
.
out
tests/025_high_precision.test
浏览文件 @
f6a9d7d7
args
:
--
allow
-
high
-
precision
--
reload
tests
/
025_
high_precision
.
ts
args
:
run
--
allow
-
high
-
precision
--
reload
tests
/
025_
high_precision
.
ts
output
:
tests
/
025_
high_precision
.
ts
.
out
tests/025_reload_js_type_error.test
浏览文件 @
f6a9d7d7
args
:
--
reload
tests
/
025_
reload_js_type_error
.
js
args
:
run
--
reload
tests
/
025_
reload_js_type_error
.
js
output
:
tests
/
025_
reload_js_type_error
.
js
.
out
tests/026_redirect_javascript.js.test
浏览文件 @
f6a9d7d7
args
:
--
reload
tests
/
026_
redirect_javascript
.
js
args
:
run
--
reload
tests
/
026_
redirect_javascript
.
js
output
:
tests
/
026_
redirect_javascript
.
js
.
out
tests/026_workers.test
浏览文件 @
f6a9d7d7
args
:
--
reload
tests
/
026_
workers
.
ts
args
:
run
--
reload
tests
/
026_
workers
.
ts
output
:
tests
/
026_
workers
.
ts
.
out
tests/027_redirect_typescript.ts.test
浏览文件 @
f6a9d7d7
args
:
--
reload
tests
/
027_
redirect_typescript
.
ts
args
:
run
--
reload
tests
/
027_
redirect_typescript
.
ts
output
:
tests
/
027_
redirect_typescript
.
ts
.
out
tests/028_args.test
浏览文件 @
f6a9d7d7
args
:
--
reload
tests
/
02
8_
args
.
ts
--
arg1
val1
--
arg2
=
val2
--
arg3
arg4
args
:
run
--
reload
tests
/
02
8_
args
.
ts
--
arg1
val1
--
arg2
=
val2
--
arg3
arg4
output
:
tests
/
02
8_
args
.
ts
.
out
tests/async_error.test
浏览文件 @
f6a9d7d7
exit_code
:
1
args
:
--
reload
tests
/
async_error
.
ts
args
:
run
--
reload
tests
/
async_error
.
ts
check_stderr
:
true
output
:
tests
/
async_error
.
ts
.
out
tests/circular1.test
浏览文件 @
f6a9d7d7
args
:
tests
/
circular1
.
js
--
reload
args
:
run
--
reload
tests
/
circular1
.
js
output
:
tests
/
circular1
.
js
.
out
tests/config.test
浏览文件 @
f6a9d7d7
args
:
--
reload
--
config
tests
/
config
.
tsconfig
.
json
tests
/
config
.
ts
args
:
run
--
reload
--
config
tests
/
config
.
tsconfig
.
json
tests
/
config
.
ts
check_stderr
:
true
exit_code
:
1
output
:
tests
/
config
.
ts
.
out
tests/error_001.test
浏览文件 @
f6a9d7d7
args
:
--
reload
tests
/
error_001
.
ts
args
:
run
--
reload
tests
/
error_001
.
ts
check_stderr
:
true
exit_code
:
1
output
:
tests
/
error_001
.
ts
.
out
tests/error_002.test
浏览文件 @
f6a9d7d7
args
:
--
reload
tests
/
error_002
.
ts
args
:
run
--
reload
tests
/
error_002
.
ts
check_stderr
:
true
exit_code
:
1
output
:
tests
/
error_002
.
ts
.
out
tests/error_003_typescript.test
浏览文件 @
f6a9d7d7
args
:
--
reload
tests
/
error_003_typescript
.
ts
args
:
run
--
reload
tests
/
error_003_typescript
.
ts
exit_code
:
1
output
:
tests
/
error_003_typescript
.
ts
.
out
tests/error_004_missing_module.test
浏览文件 @
f6a9d7d7
args
:
tests
/
error_004_missing_module
.
ts
--
reload
args
:
run
--
reload
tests
/
error_004_missing_module
.
ts
check_stderr
:
true
exit_code
:
1
output
:
tests
/
error_004_missing_module
.
ts
.
out
tests/error_005_missing_dynamic_import.test
浏览文件 @
f6a9d7d7
args
:
tests
/
error_005_missing_dynamic_import
.
ts
--
reload
args
:
run
--
reload
tests
/
error_005_missing_dynamic_import
.
ts
check_stderr
:
true
exit_code
:
1
output
:
tests
/
error_005_missing_dynamic_import
.
ts
.
out
tests/error_006_import_ext_failure.test
浏览文件 @
f6a9d7d7
args
:
tests
/
error_006_import_ext_failure
.
ts
--
reload
args
:
run
--
reload
tests
/
error_006_import_ext_failure
.
ts
check_stderr
:
true
exit_code
:
1
output
:
tests
/
error_006_import_ext_failure
.
ts
.
out
tests/error_007_any.test
浏览文件 @
f6a9d7d7
args
:
--
reload
tests
/
error_007_any
.
ts
args
:
run
--
reload
tests
/
error_007_any
.
ts
check_stderr
:
true
exit_code
:
1
output
:
tests
/
error_007_any
.
ts
.
out
tests/error_008_checkjs.test
浏览文件 @
f6a9d7d7
args
:
--
reload
tests
/
error_008_checkjs
.
js
args
:
run
--
reload
tests
/
error_008_checkjs
.
js
check_stderr
:
true
exit_code
:
1
output
:
tests
/
error_008_checkjs
.
js
.
out
tests/error_syntax.test
浏览文件 @
f6a9d7d7
args
:
--
reload
tests
/
error_syntax
.
js
args
:
run
--
reload
tests
/
error_syntax
.
js
check_stderr
:
true
exit_code
:
1
output
:
tests
/
error_syntax
.
js
.
out
tests/exit_error42.test
浏览文件 @
f6a9d7d7
exit_code
:
42
args
:
--
reload
tests
/
exit_error42
.
ts
args
:
run
--
reload
tests
/
exit_error42
.
ts
output
:
tests
/
exit_error42
.
ts
.
out
tests/https_import.test
浏览文件 @
f6a9d7d7
args
:
--
reload
tests
/
https_import
.
ts
args
:
run
--
reload
tests
/
https_import
.
ts
output
:
tests
/
https_import
.
ts
.
out
tests/if_main.test
浏览文件 @
f6a9d7d7
args
:
--
reload
tests
/
if_main
.
ts
args
:
run
--
reload
tests
/
if_main
.
ts
output
:
tests
/
if_main
.
ts
.
out
tests/import_meta.test
浏览文件 @
f6a9d7d7
args
:
--
reload
tests
/
import_meta
.
ts
args
:
run
--
reload
tests
/
import_meta
.
ts
output
:
tests
/
import_meta
.
ts
.
out
tests/unbuffered_stderr.test
浏览文件 @
f6a9d7d7
args
:
--
reload
tests
/
unbuffered_stderr
.
ts
args
:
run
--
reload
tests
/
unbuffered_stderr
.
ts
check_stderr
:
true
output
:
tests
/
unbuffered_stderr
.
ts
.
out
tests/unbuffered_stdout.test
浏览文件 @
f6a9d7d7
args
:
--
reload
tests
/
unbuffered_stdout
.
ts
args
:
run
--
reload
tests
/
unbuffered_stdout
.
ts
output
:
tests
/
unbuffered_stdout
.
ts
.
out
tests/v8_flags.test
浏览文件 @
f6a9d7d7
args
:
--
v8
-
flags
=--
expose
-
gc
tests
/
v8_flags
.
js
args
:
run
--
v8
-
flags
=--
expose
-
gc
tests
/
v8_flags
.
js
output
:
tests
/
v8_flags
.
js
.
out
tests/wasm.test
浏览文件 @
f6a9d7d7
args
:
tests
/
wasm
.
ts
output
:
tests
/
wasm
.
ts
.
out
\ No newline at end of file
args
:
run
tests
/
wasm
.
ts
output
:
tests
/
wasm
.
ts
.
out
tools/benchmark.py
浏览文件 @
f6a9d7d7
...
...
@@ -143,7 +143,7 @@ def run_strace_benchmarks(deno_exe, new_data):
thread_count
=
{}
syscall_count
=
{}
for
(
name
,
args
)
in
exec_time_benchmarks
:
s
=
get_strace_summary
([
deno_exe
]
+
args
)
s
=
get_strace_summary
([
deno_exe
,
"run"
]
+
args
)
thread_count
[
name
]
=
s
[
"clone"
][
"calls"
]
+
1
syscall_count
[
name
]
=
s
[
"total"
][
"calls"
]
new_data
[
"thread_count"
]
=
thread_count
...
...
@@ -162,7 +162,7 @@ def find_max_mem_in_bytes(time_v_output):
def
run_max_mem_benchmark
(
deno_exe
):
results
=
{}
for
(
name
,
args
)
in
exec_time_benchmarks
:
cmd
=
[
"/usr/bin/time"
,
"-v"
,
deno_exe
]
+
args
cmd
=
[
"/usr/bin/time"
,
"-v"
,
deno_exe
,
"run"
]
+
args
try
:
out
=
subprocess
.
check_output
(
cmd
,
stderr
=
subprocess
.
STDOUT
)
except
subprocess
.
CalledProcessError
:
...
...
@@ -179,7 +179,8 @@ def run_exec_time(deno_exe, build_dir):
hyperfine
,
"--ignore-failure"
,
"--export-json"
,
benchmark_file
,
"--warmup"
,
"3"
]
+
[
deno_exe
+
" "
+
" "
.
join
(
args
)
for
[
_
,
args
]
in
exec_time_benchmarks
deno_exe
+
" run "
+
" "
.
join
(
args
)
for
[
_
,
args
]
in
exec_time_benchmarks
])
hyperfine_results
=
read_json
(
benchmark_file
)
results
=
{}
...
...
tools/deno_dir_test.py
浏览文件 @
f6a9d7d7
...
...
@@ -35,7 +35,7 @@ def deno_dir_test(deno_exe, deno_dir):
def
run_deno
(
deno_exe
,
deno_dir
=
None
):
cmd
=
[
deno_exe
,
"tests/002_hello.ts"
]
cmd
=
[
deno_exe
,
"
run"
,
"
tests/002_hello.ts"
]
deno_dir_env
=
{
"DENO_DIR"
:
deno_dir
}
if
deno_dir
is
not
None
else
None
run
(
cmd
,
quiet
=
True
,
env
=
deno_dir_env
)
...
...
tools/http_benchmark.py
浏览文件 @
f6a9d7d7
...
...
@@ -11,14 +11,14 @@ DURATION = "10s"
def
deno_http_benchmark
(
deno_exe
):
deno_cmd
=
[
deno_exe
,
"--allow-net"
,
"tests/http_bench.ts"
,
ADDR
]
deno_cmd
=
[
deno_exe
,
"
run"
,
"
--allow-net"
,
"tests/http_bench.ts"
,
ADDR
]
print
"http_benchmark testing DENO."
return
run
(
deno_cmd
)
def
deno_net_http_benchmark
(
deno_exe
):
deno_cmd
=
[
deno_exe
,
"--allow-net"
,
deno_exe
,
"
run"
,
"
--allow-net"
,
"js/deps/https/deno.land/std/http/http_bench.ts"
,
ADDR
]
print
"http_benchmark testing DENO using net/http."
...
...
tools/is_tty_test.py
浏览文件 @
f6a9d7d7
...
...
@@ -12,7 +12,7 @@ IS_TTY_TEST_TS = "tests/is_tty.ts"
def
is_tty_test
(
deno_exe
):
cmd
=
[
deno_exe
,
IS_TTY_TEST_TS
]
cmd
=
[
deno_exe
,
"run"
,
IS_TTY_TEST_TS
]
code
,
stdout
,
_
=
tty_capture
(
cmd
,
b
''
)
assert
code
==
0
assert
str
(
stdin
.
isatty
()).
lower
()
in
stdout
...
...
tools/permission_prompt_test.py
浏览文件 @
f6a9d7d7
...
...
@@ -71,7 +71,8 @@ class Prompt(object):
def
run
(
self
,
flags
,
args
,
bytes_input
):
"Returns (return_code, stdout, stderr)."
cmd
=
[
self
.
deno_exe
]
+
flags
+
[
PERMISSIONS_PROMPT_TEST_TS
]
+
args
cmd
=
[
self
.
deno_exe
,
"run"
]
+
flags
+
[
PERMISSIONS_PROMPT_TEST_TS
]
+
args
return
tty_capture
(
cmd
,
bytes_input
)
def
warm_up
(
self
):
...
...
tools/repl_test.py
浏览文件 @
f6a9d7d7
...
...
@@ -19,7 +19,7 @@ class Repl(object):
def
input
(
self
,
*
lines
,
**
kwargs
):
exit_
=
kwargs
.
pop
(
"exit"
,
True
)
sleep_
=
kwargs
.
pop
(
"sleep"
,
0
)
p
=
Popen
([
self
.
deno_exe
,
"-A"
],
stdout
=
PIPE
,
stderr
=
PIPE
,
stdin
=
PIPE
)
p
=
Popen
([
self
.
deno_exe
],
stdout
=
PIPE
,
stderr
=
PIPE
,
stdin
=
PIPE
)
try
:
# Note: The repl takes a >100ms until it's ready.
time
.
sleep
(
sleep_
)
...
...
tools/test.py
浏览文件 @
f6a9d7d7
...
...
@@ -30,16 +30,16 @@ def test_no_color(deno_exe):
sys
.
stdout
.
write
(
"no_color test..."
)
sys
.
stdout
.
flush
()
t
=
os
.
path
.
join
(
tests_path
,
"no_color.js"
)
output
=
run_output
([
deno_exe
,
t
],
merge_env
=
{
"NO_COLOR"
:
"1"
})
output
=
run_output
([
deno_exe
,
"run"
,
t
],
merge_env
=
{
"NO_COLOR"
:
"1"
})
assert
output
.
strip
()
==
"noColor true"
t
=
os
.
path
.
join
(
tests_path
,
"no_color.js"
)
output
=
run_output
([
deno_exe
,
t
])
output
=
run_output
([
deno_exe
,
"run"
,
t
])
assert
output
.
strip
()
==
"noColor false"
print
green_ok
()
def
exec_path_test
(
deno_exe
):
cmd
=
[
deno_exe
,
"tests/exec_path.ts"
]
cmd
=
[
deno_exe
,
"
run"
,
"
tests/exec_path.ts"
]
output
=
run_output
(
cmd
)
assert
deno_exe
in
output
.
strip
()
...
...
tools/throughput_benchmark.py
浏览文件 @
f6a9d7d7
...
...
@@ -19,7 +19,8 @@ ADDR = "127.0.0.1:4544"
def
cat
(
deno_exe
,
megs
):
size
=
megs
*
MB
start
=
time
.
time
()
cmd
=
deno_exe
+
" --allow-read tests/cat.ts /dev/zero | head -c %s "
%
size
cmd
=
deno_exe
+
" run --allow-read "
cmd
+=
"tests/cat.ts /dev/zero | head -c %s "
%
size
print
cmd
subprocess
.
check_output
(
cmd
,
shell
=
True
)
end
=
time
.
time
()
...
...
@@ -30,7 +31,7 @@ def tcp(deno_exe, megs):
size
=
megs
*
MB
# Run deno echo server in the background.
echo_server
=
subprocess
.
Popen
(
[
deno_exe
,
"--allow-net"
,
"tests/echo_server.ts"
,
ADDR
])
[
deno_exe
,
"
run"
,
"
--allow-net"
,
"tests/echo_server.ts"
,
ADDR
])
time
.
sleep
(
5
)
# wait for deno to wake up. TODO racy.
try
:
...
...
tools/unit_tests.py
浏览文件 @
f6a9d7d7
...
...
@@ -34,7 +34,7 @@ def run_unit_test2(cmd):
def
run_unit_test
(
deno_exe
,
permStr
,
flags
=
None
):
if
flags
is
None
:
flags
=
[]
cmd
=
[
deno_exe
]
+
flags
+
[
"js/unit_tests.ts"
,
permStr
]
cmd
=
[
deno_exe
,
"run"
]
+
flags
+
[
"js/unit_tests.ts"
,
permStr
]
run_unit_test2
(
cmd
)
...
...
website/index.html
浏览文件 @
f6a9d7d7
...
...
@@ -104,7 +104,7 @@ href="https://github.com/denoland/deno_install/blob/master/install.ps1">https://
<h2
id=
"example"
>
Example
<a
href=
"#example"
>
#
</a></h2>
<p>
Try running a simple program:
</p>
<pre>
deno https://deno.land/welcome.ts
</pre>
<pre>
deno
run
https://deno.land/welcome.ts
</pre>
<p>
Or a more complex one:
</p>
...
...
website/manual.md
浏览文件 @
f6a9d7d7
...
...
@@ -543,31 +543,24 @@ USAGE:
deno [FLAGS] [OPTIONS] [SUBCOMMAND]
FLAGS:
-A, --allow-all Allow all permissions
--allow-env Allow environment access
--allow-high-precision Allow high precision time measurement
--allow-net Allow network access
--allow-read Allow file system read access
--allow-run Allow running subprocesses
--allow-write Allow file system write access
-h, --help Prints help information
-D, --log-debug Log debug output
--no-prompt Do not use prompts
-r, --reload Reload source code cache (recompile TypeScript)
--v8-options Print V8 command line options
-h, --help Prints help information
-D, --log-debug Log debug output
-r, --reload Reload source code cache (recompile TypeScript)
--v8-options Print V8 command line options
OPTIONS:
-c, --config <FILE> Load compiler configuration file
--v8-flags=<v8-flags> Set V8 command line options
SUBCOMMANDS:
<script> Script to run
eval Eval script
f
etch Fetch the dependenci
es
fmt Format files
help Prints this message or the help of the given subcommand(s)
info Show source file related info
types
Print runtime TypeScript declarations
version
Print the version
eval Eval script
fetch Fetch the dependencies
f
mt Format fil
es
help Prints this message or the help of the given subcommand(s)
info Show source file related info
run Run a program given a filename or url to the source code
types Print runtime TypeScript declarations
version Print the version
ENVIRONMENT VARIABLES:
DENO_DIR Set deno's base directory
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录