Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
deno
提交
780e72ab
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,发现更多精彩内容 >>
提交
780e72ab
编写于
4月 07, 2019
作者:
B
Bartek Iwańczuk
提交者:
Ryan Dahl
4月 07, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactor CLI flag parsing (#2025)
上级
cb11bbd8
变更
49
隐藏空白更改
内联
并排
Showing
49 changed file
with
328 addition
and
245 deletion
+328
-245
Cargo.lock
Cargo.lock
+0
-10
cli/BUILD.gn
cli/BUILD.gn
+0
-1
cli/Cargo.toml
cli/Cargo.toml
+0
-1
cli/flags.rs
cli/flags.rs
+211
-135
cli/isolate.rs
cli/isolate.rs
+2
-2
cli/isolate_state.rs
cli/isolate_state.rs
+1
-1
cli/main.rs
cli/main.rs
+4
-7
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/010_set_interval.test
tests/010_set_interval.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/022_info_flag.test
tests/022_info_flag.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_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
+2
-2
tests/027_redirect_typescript.ts.test
tests/027_redirect_typescript.ts.test
+2
-2
tests/028_args.test
tests/028_args.test
+2
-0
tests/028_args.ts
tests/028_args.ts
+3
-0
tests/028_args.ts.out
tests/028_args.ts.out
+7
-0
tests/async_error.test
tests/async_error.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_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
tools/benchmark.py
tools/benchmark.py
+7
-7
tools/fmt_test.py
tools/fmt_test.py
+1
-1
tools/permission_prompt_test.py
tools/permission_prompt_test.py
+15
-16
tools/throughput_benchmark.py
tools/throughput_benchmark.py
+1
-1
tools/unit_tests.py
tools/unit_tests.py
+1
-1
website/manual.md
website/manual.md
+38
-27
未找到文件。
Cargo.lock
浏览文件 @
780e72ab
...
...
@@ -215,7 +215,6 @@ dependencies = [
"dirs 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
"flatbuffers 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
"getopts 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
"http 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)",
"hyper 0.12.25 (registry+https://github.com/rust-lang/crates.io-index)",
"hyper-rustls 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)",
...
...
@@ -317,14 +316,6 @@ dependencies = [
"num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "getopts"
version = "0.2.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "h2"
version = "0.1.17"
...
...
@@ -1440,7 +1431,6 @@ dependencies = [
"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
"checksum futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)" = "49e7653e374fe0d0c12de4250f0bdb60680b8c80eed558c5c7538eec9c89e21b"
"checksum futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "ab90cde24b3319636588d0c35fe03b1333857621051837ed769faefb4c2162e4"
"checksum getopts 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "0a7292d30132fb5424b354f5dc02512a86e4c516fe544bb7a25e7f266951b797"
"checksum h2 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "910a5e7be6283a9c91b3982fa5188368c8719cce2a3cf3b86048673bf9d9c36b"
"checksum http 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "fe67e3678f2827030e89cc4b9e7ecd16d52f132c0b940ab5005f88e821500f6a"
"checksum httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e8734b0cfd3bc3e101ec59100e101c2eecd19282202e87808b3037b442777a83"
...
...
cli/BUILD.gn
浏览文件 @
780e72ab
...
...
@@ -16,7 +16,6 @@ main_extern = [
"$rust_build:dirs",
"$rust_build:flatbuffers",
"$rust_build:futures",
"$rust_build:getopts",
"$rust_build:http",
"$rust_build:hyper",
"$rust_build:hyper_rustls",
...
...
cli/Cargo.toml
浏览文件 @
780e72ab
...
...
@@ -24,7 +24,6 @@ clap = "2.32.0"
dirs
=
"1.0.5"
flatbuffers
=
"0.5.0"
futures
=
"0.1.25"
getopts
=
"0.2.18"
http
=
"0.1.16"
hyper
=
"0.12.25"
hyper-rustls
=
"0.16.1"
...
...
cli/flags.rs
浏览文件 @
780e72ab
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
use
clap
::{
App
,
AppSettings
,
Arg
,
ArgMatches
,
SubCommand
};
use
deno
::
v8_set_flags
;
use
getopts
;
use
getopts
::
Options
;
// Creates vector of strings, Vec<String>
#[cfg(test)]
...
...
@@ -12,7 +11,6 @@ macro_rules! svec {
#[cfg_attr(feature
=
"cargo-clippy"
,
allow(stutter))]
#[derive(Clone,
Debug,
PartialEq,
Default)]
pub
struct
DenoFlags
{
pub
help
:
bool
,
pub
log_debug
:
bool
,
pub
version
:
bool
,
pub
reload
:
bool
,
...
...
@@ -28,16 +26,6 @@ pub struct DenoFlags {
pub
fmt
:
bool
,
}
pub
fn
get_usage
(
opts
:
&
Options
)
->
String
{
format!
(
"Usage: deno script.ts {}
Environment variables:
DENO_DIR Set deno's base directory
NO_COLOR Set to disable color"
,
opts
.usage
(
""
)
)
}
/// Checks provided arguments for known options and sets appropriate Deno flags
/// for them. Unknown options are returned for further use.
/// Note:
...
...
@@ -51,129 +39,217 @@ Environment variables:
/// not cause an error. I also think this is ok because missing any of the
/// privileged flags is not destructive. Userland flag parsing would catch these
/// errors.
fn
set_recognized_flags
(
opts
:
&
Options
,
flags
:
&
mut
DenoFlags
,
args
:
Vec
<
String
>
,
)
->
Result
<
Vec
<
String
>
,
getopts
::
Fail
>
{
let
mut
rest
=
Vec
::
<
String
>
::
new
();
// getopts doesn't allow parsing unknown options so we check them
// one-by-one and handle unrecognized ones manually
// better solution welcome!
for
arg
in
args
{
let
fake_args
=
vec!
[
arg
];
match
opts
.parse
(
&
fake_args
)
{
Err
(
getopts
::
Fail
::
UnrecognizedOption
(
_
))
=>
{
rest
.extend
(
fake_args
);
}
Err
(
e
)
=>
{
return
Err
(
e
);
}
Ok
(
matches
)
=>
{
if
matches
.opt_present
(
"help"
)
{
flags
.help
=
true
;
}
if
matches
.opt_present
(
"log-debug"
)
{
flags
.log_debug
=
true
;
}
if
matches
.opt_present
(
"version"
)
{
flags
.version
=
true
;
}
if
matches
.opt_present
(
"reload"
)
{
flags
.reload
=
true
;
}
if
matches
.opt_present
(
"allow-read"
)
{
flags
.allow_read
=
true
;
}
if
matches
.opt_present
(
"allow-write"
)
{
flags
.allow_write
=
true
;
}
if
matches
.opt_present
(
"allow-net"
)
{
flags
.allow_net
=
true
;
}
if
matches
.opt_present
(
"allow-env"
)
{
flags
.allow_env
=
true
;
}
if
matches
.opt_present
(
"allow-run"
)
{
flags
.allow_run
=
true
;
}
if
matches
.opt_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
;
}
if
matches
.opt_present
(
"no-prompt"
)
{
flags
.no_prompts
=
true
;
}
if
matches
.opt_present
(
"types"
)
{
flags
.types
=
true
;
}
if
matches
.opt_present
(
"prefetch"
)
{
flags
.prefetch
=
true
;
}
if
matches
.opt_present
(
"info"
)
{
flags
.info
=
true
;
}
if
matches
.opt_present
(
"fmt"
)
{
flags
.fmt
=
true
;
}
if
!
matches
.free
.is_empty
()
{
rest
.extend
(
matches
.free
);
}
}
}
fn
set_recognized_flags
(
matches
:
ArgMatches
,
flags
:
&
mut
DenoFlags
)
{
if
matches
.is_present
(
"log-debug"
)
{
flags
.log_debug
=
true
;
}
if
matches
.is_present
(
"version"
)
{
flags
.version
=
true
;
}
if
matches
.is_present
(
"reload"
)
{
flags
.reload
=
true
;
}
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-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
;
}
if
matches
.is_present
(
"no-prompt"
)
{
flags
.no_prompts
=
true
;
}
if
matches
.is_present
(
"types"
)
{
flags
.types
=
true
;
}
if
matches
.is_present
(
"prefetch"
)
{
flags
.prefetch
=
true
;
}
if
matches
.is_present
(
"info"
)
{
flags
.info
=
true
;
}
if
matches
.is_present
(
"fmt"
)
{
flags
.fmt
=
true
;
}
Ok
(
rest
)
}
#[cfg_attr(feature
=
"cargo-clippy"
,
allow(stutter))]
pub
fn
set_flags
(
args
:
Vec
<
String
>
,
)
->
Result
<
(
DenoFlags
,
Vec
<
String
>
,
String
),
String
>
{
// TODO: all flags passed after "--" are swallowed by v8_set_flags
// eg. deno --allow-net ./test.ts -- --title foobar
// args === ["deno", "--allow-net" "./test.ts"]
let
args
=
v8_set_flags
(
args
)
;
)
->
Result
<
(
DenoFlags
,
Vec
<
String
>
),
String
>
{
let
app_settings
:
Vec
<
AppSettings
>
=
vec!
[
AppSettings
::
AllowExternalSubcommands
,
AppSettings
::
DisableHelpSubcommand
,
]
;
let
mut
opts
=
Options
::
new
();
// TODO(kevinkassimo): v8_set_flags intercepts '-help' with single '-'
// Resolve that and then uncomment line below (enabling Go style -long-flag)
// opts.long_only(true);
opts
.optflag
(
""
,
"allow-read"
,
"Allow file system read access"
);
opts
.optflag
(
""
,
"allow-write"
,
"Allow file system write access"
);
opts
.optflag
(
""
,
"allow-net"
,
"Allow network access"
);
opts
.optflag
(
""
,
"allow-env"
,
"Allow environment access"
);
opts
.optflag
(
""
,
"allow-run"
,
"Allow running subprocesses"
);
opts
.optflag
(
"A"
,
"allow-all"
,
"Allow all permissions"
);
opts
.optflag
(
""
,
"no-prompt"
,
"Do not use prompts"
);
opts
.optflag
(
"h"
,
"help"
,
"Print this message"
);
opts
.optflag
(
"D"
,
"log-debug"
,
"Log debug output"
);
opts
.optflag
(
"v"
,
"version"
,
"Print the version"
);
opts
.optflag
(
"r"
,
"reload"
,
"Reload source code cache (recompile TypeScript)"
,
);
opts
.optflag
(
""
,
"v8-options"
,
"Print V8 command line options"
);
opts
.optflag
(
""
,
"types"
,
"Print runtime TypeScript declarations"
);
opts
.optflag
(
""
,
"prefetch"
,
"Prefetch the dependencies"
);
opts
.optflag
(
""
,
"info"
,
"Show source file related info"
);
opts
.optflag
(
""
,
"fmt"
,
"Format code"
);
let
env_variables_help
=
"ENVIRONMENT VARIABLES:
DENO_DIR Set deno's base directory
NO_COLOR Set to disable color"
;
let
mut
flags
=
DenoFlags
::
default
();
let
clap_app
=
App
::
new
(
"deno"
)
.global_settings
(
&
vec!
[
AppSettings
::
ColorNever
])
.settings
(
&
app_settings
[
..
])
.after_help
(
env_variables_help
)
.arg
(
Arg
::
with_name
(
"version"
)
.short
(
"v"
)
.long
(
"version"
)
.help
(
"Print the version"
),
)
.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-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
(
"log-debug"
)
.short
(
"D"
)
.long
(
"log-debug"
)
.help
(
"Log debug output"
),
)
.arg
(
Arg
::
with_name
(
"reload"
)
.short
(
"r"
)
.long
(
"reload"
)
.help
(
"Reload source code cache (recompile TypeScript)"
),
)
.arg
(
Arg
::
with_name
(
"v8-options"
)
.long
(
"v8-options"
)
.help
(
"Print V8 command line options"
),
)
.arg
(
Arg
::
with_name
(
"v8-flags"
)
.long
(
"v8-flags"
)
.takes_value
(
true
)
.require_equals
(
true
)
.help
(
"Set V8 command line options"
),
)
.arg
(
Arg
::
with_name
(
"types"
)
.long
(
"types"
)
.help
(
"Print runtime TypeScript declarations"
),
)
.arg
(
Arg
::
with_name
(
"prefetch"
)
.long
(
"prefetch"
)
.help
(
"Prefetch the dependencies"
),
)
.subcommand
(
// TODO(bartlomieju): version is not handled properly
SubCommand
::
with_name
(
"info"
)
.about
(
"Show source file related info"
)
.arg
(
Arg
::
with_name
(
"file"
)
.takes_value
(
true
)
.required
(
true
)),
)
.subcommand
(
// TODO(bartlomieju): version is not handled properly
SubCommand
::
with_name
(
"fmt"
)
.about
(
"Format files"
)
.arg
(
Arg
::
with_name
(
"files"
)
.takes_value
(
true
)
.multiple
(
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"
),
);
let
rest
=
set_recognized_flags
(
&
opts
,
&
mut
flags
,
args
)
.map_err
(|
e
|
e
.to_string
())
?
;
Ok
((
flags
,
rest
,
get_usage
(
&
opts
)))
let
matches
=
clap_app
.get_matches_from
(
args
);
// TODO(bartomieju): compatibility with old "opts" approach - to be refactored
let
mut
rest
:
Vec
<
String
>
=
vec!
[
String
::
from
(
"deno"
)];
match
matches
.subcommand
()
{
(
"info"
,
Some
(
info_match
))
=>
{
// TODO(bartlomieju): it still relies on `is_present("info")` check
// in `set_recognized_flags`
let
file
:
&
str
=
info_match
.value_of
(
"file"
)
.unwrap
();
rest
.extend
(
vec!
[
file
.to_string
()]);
}
(
"fmt"
,
Some
(
fmt_match
))
=>
{
// TODO(bartlomieju): it still relies on `is_present("fmt")` check
// in `set_recognized_flags`
let
files
:
Vec
<
String
>
=
fmt_match
.values_of
(
"files"
)
.unwrap
()
.map
(
String
::
from
)
.collect
();
rest
.extend
(
files
);
}
(
script
,
Some
(
script_match
))
=>
{
rest
.extend
(
vec!
[
script
.to_string
()]);
// check if there are any extra arguments
if
script_match
.is_present
(
""
)
{
let
script_args
:
Vec
<
String
>
=
script_match
.values_of
(
""
)
.unwrap
()
.map
(
String
::
from
)
.collect
();
rest
.extend
(
script_args
);
}
}
_
=>
{}
}
// TODO: end
if
matches
.is_present
(
"v8-options"
)
{
// display v8 help and exit
v8_set_flags
(
vec!
[
"deno"
.to_string
(),
"--help"
.to_string
()]);
}
if
matches
.is_present
(
"v8-flags"
)
{
let
mut
v8_flags
:
Vec
<
String
>
=
matches
.values_of
(
"v8-flags"
)
.unwrap
()
.map
(
String
::
from
)
.collect
();
v8_flags
.insert
(
1
,
"deno"
.to_string
());
v8_set_flags
(
v8_flags
);
}
let
mut
flags
=
DenoFlags
::
default
();
set_recognized_flags
(
matches
,
&
mut
flags
);
Ok
((
flags
,
rest
))
}
#[test]
fn
test_set_flags_1
()
{
let
(
flags
,
rest
,
_
)
=
set_flags
(
svec!
[
"deno"
,
"--version"
])
.unwrap
();
let
(
flags
,
rest
)
=
set_flags
(
svec!
[
"deno"
,
"--version"
])
.unwrap
();
assert_eq!
(
rest
,
svec!
[
"deno"
]);
assert_eq!
(
flags
,
...
...
@@ -186,7 +262,7 @@ fn test_set_flags_1() {
#[test]
fn
test_set_flags_2
()
{
let
(
flags
,
rest
,
_
)
=
let
(
flags
,
rest
)
=
set_flags
(
svec!
[
"deno"
,
"-r"
,
"-D"
,
"script.ts"
])
.unwrap
();
assert_eq!
(
rest
,
svec!
[
"deno"
,
"script.ts"
]);
assert_eq!
(
...
...
@@ -201,8 +277,8 @@ fn test_set_flags_2() {
#[test]
fn
test_set_flags_3
()
{
let
(
flags
,
rest
,
_
)
=
set_flags
(
svec!
[
"deno"
,
"-r"
,
"
script.ts"
,
"--allow-write
"
])
.unwrap
();
let
(
flags
,
rest
)
=
set_flags
(
svec!
[
"deno"
,
"-r"
,
"
--allow-write"
,
"script.ts
"
])
.unwrap
();
assert_eq!
(
rest
,
svec!
[
"deno"
,
"script.ts"
]);
assert_eq!
(
flags
,
...
...
@@ -216,8 +292,8 @@ fn test_set_flags_3() {
#[test]
fn
test_set_flags_4
()
{
let
(
flags
,
rest
,
_
)
=
set_flags
(
svec!
[
"deno"
,
"-Dr"
,
"
script.ts"
,
"--allow-write
"
])
.unwrap
();
let
(
flags
,
rest
)
=
set_flags
(
svec!
[
"deno"
,
"-Dr"
,
"
--allow-write"
,
"script.ts
"
])
.unwrap
();
assert_eq!
(
rest
,
svec!
[
"deno"
,
"script.ts"
]);
assert_eq!
(
flags
,
...
...
@@ -232,7 +308,7 @@ fn test_set_flags_4() {
#[test]
fn
test_set_flags_5
()
{
let
(
flags
,
rest
,
_
)
=
set_flags
(
svec!
[
"deno"
,
"--types"
])
.unwrap
();
let
(
flags
,
rest
)
=
set_flags
(
svec!
[
"deno"
,
"--types"
])
.unwrap
();
assert_eq!
(
rest
,
svec!
[
"deno"
]);
assert_eq!
(
flags
,
...
...
@@ -245,8 +321,8 @@ fn test_set_flags_5() {
#[test]
fn
test_set_flags_6
()
{
let
(
flags
,
rest
,
_
)
=
set_flags
(
svec!
[
"deno"
,
"
gist.ts"
,
"--title"
,
"X"
,
"--allow-net
"
])
.unwrap
();
let
(
flags
,
rest
)
=
set_flags
(
svec!
[
"deno"
,
"
--allow-net"
,
"gist.ts"
,
"--title"
,
"X
"
])
.unwrap
();
assert_eq!
(
rest
,
svec!
[
"deno"
,
"gist.ts"
,
"--title"
,
"X"
]);
assert_eq!
(
flags
,
...
...
@@ -259,8 +335,8 @@ fn test_set_flags_6() {
#[test]
fn
test_set_flags_7
()
{
let
(
flags
,
rest
,
_
)
=
set_flags
(
svec!
[
"deno"
,
"
gist.ts"
,
"--allow-all
"
])
.unwrap
();
let
(
flags
,
rest
)
=
set_flags
(
svec!
[
"deno"
,
"
--allow-all"
,
"gist.ts
"
])
.unwrap
();
assert_eq!
(
rest
,
svec!
[
"deno"
,
"gist.ts"
]);
assert_eq!
(
flags
,
...
...
@@ -277,8 +353,8 @@ fn test_set_flags_7() {
#[test]
fn
test_set_flags_8
()
{
let
(
flags
,
rest
,
_
)
=
set_flags
(
svec!
[
"deno"
,
"
gist.ts"
,
"--allow-read
"
])
.unwrap
();
let
(
flags
,
rest
)
=
set_flags
(
svec!
[
"deno"
,
"
--allow-read"
,
"gist.ts
"
])
.unwrap
();
assert_eq!
(
rest
,
svec!
[
"deno"
,
"gist.ts"
]);
assert_eq!
(
flags
,
...
...
cli/isolate.rs
浏览文件 @
780e72ab
...
...
@@ -265,7 +265,7 @@ mod tests {
let
filename
=
filename
.to_str
()
.unwrap
()
.to_string
();
let
argv
=
vec!
[
String
::
from
(
"./deno"
),
filename
.clone
()];
let
(
flags
,
rest_argv
,
_
)
=
flags
::
set_flags
(
argv
)
.unwrap
();
let
(
flags
,
rest_argv
)
=
flags
::
set_flags
(
argv
)
.unwrap
();
let
state
=
Arc
::
new
(
IsolateState
::
new
(
flags
,
rest_argv
,
None
,
false
));
let
state_
=
state
.clone
();
...
...
@@ -288,7 +288,7 @@ mod tests {
let
filename
=
filename
.to_str
()
.unwrap
()
.to_string
();
let
argv
=
vec!
[
String
::
from
(
"./deno"
),
filename
.clone
()];
let
(
flags
,
rest_argv
,
_
)
=
flags
::
set_flags
(
argv
)
.unwrap
();
let
(
flags
,
rest_argv
)
=
flags
::
set_flags
(
argv
)
.unwrap
();
let
state
=
Arc
::
new
(
IsolateState
::
new
(
flags
,
rest_argv
,
None
,
false
));
let
state_
=
state
.clone
();
...
...
cli/isolate_state.rs
浏览文件 @
780e72ab
...
...
@@ -122,7 +122,7 @@ impl IsolateState {
pub
fn
mock
()
->
IsolateState
{
let
argv
=
vec!
[
String
::
from
(
"./deno"
),
String
::
from
(
"hello.js"
)];
// For debugging: argv.push_back(String::from("-D"));
let
(
flags
,
rest_argv
,
_
)
=
flags
::
set_flags
(
argv
)
.unwrap
();
let
(
flags
,
rest_argv
)
=
flags
::
set_flags
(
argv
)
.unwrap
();
IsolateState
::
new
(
flags
,
rest_argv
,
None
,
false
)
}
...
...
cli/main.rs
浏览文件 @
780e72ab
...
...
@@ -7,6 +7,8 @@ extern crate log;
extern
crate
futures
;
#[macro_use]
extern
crate
serde_json
;
extern
crate
clap
;
extern
crate
deno
;
mod
ansi
;
pub
mod
cli_behavior
;
...
...
@@ -82,17 +84,12 @@ fn main() {
log
::
set_logger
(
&
LOGGER
)
.unwrap
();
let
args
=
env
::
args
()
.collect
();
let
(
mut
flags
,
mut
rest_argv
,
usage_string
)
=
flags
::
set_flags
(
args
)
.unwrap_or_else
(|
err
|
{
let
(
mut
flags
,
mut
rest_argv
)
=
flags
::
set_flags
(
args
)
.unwrap_or_else
(|
err
|
{
eprintln!
(
"{}"
,
err
);
std
::
process
::
exit
(
1
)
});
if
flags
.help
{
println!
(
"{}"
,
&
usage_string
);
std
::
process
::
exit
(
0
);
}
log
::
set_max_level
(
if
flags
.log_debug
{
LevelFilter
::
Debug
}
else
{
...
...
tests/001_hello.test
浏览文件 @
780e72ab
args
:
tests
/
001_
hello
.
js
--
reload
args
:
--
reload
tests
/
001_
hello
.
js
output
:
tests
/
001_
hello
.
js
.
out
tests/002_hello.test
浏览文件 @
780e72ab
args
:
tests
/
002_
hello
.
ts
--
reload
args
:
--
reload
tests
/
002_
hello
.
ts
output
:
tests
/
002_
hello
.
ts
.
out
tests/003_relative_import.test
浏览文件 @
780e72ab
args
:
tests
/
003_
relative_import
.
ts
--
reload
args
:
--
reload
tests
/
003_
relative_import
.
ts
output
:
tests
/
003_
relative_import
.
ts
.
out
tests/004_set_timeout.test
浏览文件 @
780e72ab
args
:
tests
/
004_
set_timeout
.
ts
--
reload
args
:
--
reload
tests
/
004_
set_timeout
.
ts
output
:
tests
/
004_
set_timeout
.
ts
.
out
tests/005_more_imports.test
浏览文件 @
780e72ab
args
:
tests
/
005_
more_imports
.
ts
--
reload
args
:
--
reload
tests
/
005_
more_imports
.
ts
output
:
tests
/
005_
more_imports
.
ts
.
out
tests/006_url_imports.test
浏览文件 @
780e72ab
args
:
tests
/
006_
url_imports
.
ts
--
reload
args
:
--
reload
tests
/
006_
url_imports
.
ts
output
:
tests
/
006_
url_imports
.
ts
.
out
tests/010_set_interval.test
浏览文件 @
780e72ab
args
:
tests
/
010_
set_interval
.
ts
--
reload
args
:
--
reload
tests
/
010_
set_interval
.
ts
output
:
tests
/
010_
set_interval
.
ts
.
out
tests/012_async.test
浏览文件 @
780e72ab
args
:
tests
/
012_
async
.
ts
--
reload
args
:
--
reload
tests
/
012_
async
.
ts
output
:
tests
/
012_
async
.
ts
.
out
tests/016_double_await.test
浏览文件 @
780e72ab
args
:
tests
/
016_
double_await
.
ts
--
allow
-
read
--
reload
args
:
--
allow
-
read
--
reload
tests
/
016_
double_await
.
ts
output
:
tests
/
016_
double_await
.
ts
.
out
tests/017_import_redirect.test
浏览文件 @
780e72ab
args
:
tests
/
017_
import_redirect
.
ts
--
reload
args
:
--
reload
tests
/
017_
import_redirect
.
ts
output
:
tests
/
017_
import_redirect
.
ts
.
out
tests/018_async_catch.test
浏览文件 @
780e72ab
args
:
tests
/
01
8_
async_catch
.
ts
--
reload
args
:
--
reload
tests
/
01
8_
async_catch
.
ts
output
:
tests
/
01
8_
async_catch
.
ts
.
out
tests/019_media_types.test
浏览文件 @
780e72ab
args
:
tests
/
01
9_
media_types
.
ts
--
reload
args
:
--
reload
tests
/
01
9_
media_types
.
ts
output
:
tests
/
01
9_
media_types
.
ts
.
out
tests/020_json_modules.test
浏览文件 @
780e72ab
args
:
tests
/
020_
json_modules
.
ts
--
reload
args
:
--
reload
tests
/
020_
json_modules
.
ts
output
:
tests
/
020_
json_modules
.
ts
.
out
tests/022_info_flag.test
浏览文件 @
780e72ab
# The output assumes 003_relative_import.ts has already been run earlier
# and its output is cached to $DENO_DIR.
args
:
--
info
http
://
127.0.0.1
:
4545
/
tests
/
01
9_
media_types
.
ts
args
:
info
http
://
127.0.0.1
:
4545
/
tests
/
01
9_
media_types
.
ts
output
:
tests
/
022_
info_flag
.
out
tests/023_no_ext_with_headers.test
浏览文件 @
780e72ab
args
:
tests
/
023_
no_ext_with_headers
--
reload
args
:
--
reload
tests
/
023_
no_ext_with_headers
output
:
tests
/
023_
no_ext_with_headers
.
out
tests/024_import_no_ext_with_headers.test
浏览文件 @
780e72ab
args
:
tests
/
024_
import_no_ext_with_headers
.
ts
--
reload
args
:
--
reload
tests
/
024_
import_no_ext_with_headers
.
ts
output
:
tests
/
024_
import_no_ext_with_headers
.
ts
.
out
tests/025_reload_js_type_error.test
浏览文件 @
780e72ab
args
:
tests
/
025_
reload_js_type_error
.
js
--
reload
args
:
--
reload
tests
/
025_
reload_js_type_error
.
js
output
:
tests
/
025_
reload_js_type_error
.
js
.
out
tests/026_redirect_javascript.js.test
浏览文件 @
780e72ab
args
:
tests
/
026_
redirect_javascript
.
js
--
reload
args
:
--
reload
tests
/
026_
redirect_javascript
.
js
output
:
tests
/
026_
redirect_javascript
.
js
.
out
tests/026_workers.test
浏览文件 @
780e72ab
args
:
tests
/
026_
workers
.
ts
--
reload
output
:
tests
/
026_
workers
.
ts
.
out
\ No newline at end of file
args
:
--
reload
tests
/
026_
workers
.
ts
output
:
tests
/
026_
workers
.
ts
.
out
tests/027_redirect_typescript.ts.test
浏览文件 @
780e72ab
args
:
tests
/
027_
redirect_typescript
.
ts
--
reload
output
:
tests
/
027_
redirect_typescript
.
ts
.
out
\ No newline at end of file
args
:
--
reload
tests
/
027_
redirect_typescript
.
ts
output
:
tests
/
027_
redirect_typescript
.
ts
.
out
tests/028_args.test
0 → 100644
浏览文件 @
780e72ab
args
:
--
reload
tests
/
02
8_
args
.
ts
--
arg1
val1
--
arg2
=
val2
--
arg3
arg4
output
:
tests
/
02
8_
args
.
ts
.
out
tests/028_args.ts
0 → 100644
浏览文件 @
780e72ab
Deno
.
args
.
forEach
(
arg
=>
{
console
.
log
(
arg
);
});
tests/028_args.ts.out
0 → 100644
浏览文件 @
780e72ab
tests/028_args.ts
--arg1
val1
--arg2=val2
--
arg3
arg4
tests/async_error.test
浏览文件 @
780e72ab
exit_code
:
1
args
:
tests
/
async_error
.
ts
--
reload
args
:
--
reload
tests
/
async_error
.
ts
check_stderr
:
true
output
:
tests
/
async_error
.
ts
.
out
tests/error_001.test
浏览文件 @
780e72ab
args
:
tests
/
error_001
.
ts
--
reload
args
:
--
reload
tests
/
error_001
.
ts
check_stderr
:
true
exit_code
:
1
output
:
tests
/
error_001
.
ts
.
out
tests/error_002.test
浏览文件 @
780e72ab
args
:
tests
/
error_002
.
ts
--
reload
args
:
--
reload
tests
/
error_002
.
ts
check_stderr
:
true
exit_code
:
1
output
:
tests
/
error_002
.
ts
.
out
tests/error_003_typescript.test
浏览文件 @
780e72ab
args
:
tests
/
error_003_typescript
.
ts
--
reload
args
:
--
reload
tests
/
error_003_typescript
.
ts
exit_code
:
1
output
:
tests
/
error_003_typescript
.
ts
.
out
tests/error_007_any.test
浏览文件 @
780e72ab
args
:
tests
/
error_007_any
.
ts
--
reload
args
:
--
reload
tests
/
error_007_any
.
ts
check_stderr
:
true
exit_code
:
1
output
:
tests
/
error_007_any
.
ts
.
out
tests/error_008_checkjs.test
浏览文件 @
780e72ab
args
:
tests
/
error_008_checkjs
.
js
--
reload
args
:
--
reload
tests
/
error_008_checkjs
.
js
check_stderr
:
true
exit_code
:
1
output
:
tests
/
error_008_checkjs
.
js
.
out
tests/error_syntax.test
浏览文件 @
780e72ab
args
:
tests
/
error_syntax
.
js
--
reload
args
:
--
reload
tests
/
error_syntax
.
js
check_stderr
:
true
exit_code
:
1
output
:
tests
/
error_syntax
.
js
.
out
tests/exit_error42.test
浏览文件 @
780e72ab
exit_code
:
42
args
:
tests
/
exit_error42
.
ts
--
reload
args
:
--
reload
tests
/
exit_error42
.
ts
output
:
tests
/
exit_error42
.
ts
.
out
tests/https_import.test
浏览文件 @
780e72ab
args
:
tests
/
https_import
.
ts
--
reload
args
:
--
reload
tests
/
https_import
.
ts
output
:
tests
/
https_import
.
ts
.
out
tests/if_main.test
浏览文件 @
780e72ab
args
:
tests
/
if_main
.
ts
--
reload
args
:
--
reload
tests
/
if_main
.
ts
output
:
tests
/
if_main
.
ts
.
out
tests/import_meta.test
浏览文件 @
780e72ab
args
:
tests
/
import_meta
.
ts
--
reload
args
:
--
reload
tests
/
import_meta
.
ts
output
:
tests
/
import_meta
.
ts
.
out
tests/unbuffered_stderr.test
浏览文件 @
780e72ab
args
:
tests
/
unbuffered_stderr
.
ts
--
reload
args
:
--
reload
tests
/
unbuffered_stderr
.
ts
check_stderr
:
true
output
:
tests
/
unbuffered_stderr
.
ts
.
out
tests/unbuffered_stdout.test
浏览文件 @
780e72ab
args
:
tests
/
unbuffered_stdout
.
ts
--
reload
args
:
--
reload
tests
/
unbuffered_stdout
.
ts
output
:
tests
/
unbuffered_stdout
.
ts
.
out
tools/benchmark.py
浏览文件 @
780e72ab
...
...
@@ -23,8 +23,8 @@ exec_time_benchmarks = [
(
"hello"
,
[
"tests/002_hello.ts"
]),
(
"relative_import"
,
[
"tests/003_relative_import.ts"
]),
(
"error_001"
,
[
"tests/error_001.ts"
]),
(
"cold_hello"
,
[
"
tests/002_hello.ts"
,
"--reload
"
]),
(
"cold_relative_import"
,
[
"
tests/003_relative_import.ts"
,
"--reload
"
]),
(
"cold_hello"
,
[
"
--reload"
,
"tests/002_hello.ts
"
]),
(
"cold_relative_import"
,
[
"
--reload"
,
"tests/003_relative_import.ts
"
]),
(
"workers_startup"
,
[
"tests/workers_startup_bench.ts"
]),
(
"workers_round_robin"
,
[
"tests/workers_round_robin_bench.ts"
]),
]
...
...
@@ -127,10 +127,10 @@ def get_strace_summary(test_args):
def
run_thread_count_benchmark
(
deno_path
):
thread_count_map
=
{}
thread_count_map
[
"set_timeout"
]
=
get_strace_summary
([
deno_path
,
"
tests/004_set_timeout.ts"
,
"--reload
"
deno_path
,
"
--reload"
,
"tests/004_set_timeout.ts
"
])[
"clone"
][
"calls"
]
+
1
thread_count_map
[
"fetch_deps"
]
=
get_strace_summary
([
deno_path
,
"
tests/fetch_deps.ts"
,
"--reload"
,
"--allow-net
"
deno_path
,
"
--reload"
,
"--allow-net"
,
"tests/fetch_deps.ts
"
])[
"clone"
][
"calls"
]
+
1
return
thread_count_map
...
...
@@ -147,10 +147,10 @@ def run_throughput(deno_exe):
def
run_syscall_count_benchmark
(
deno_path
):
syscall_count_map
=
{}
syscall_count_map
[
"hello"
]
=
get_strace_summary
(
[
deno_path
,
"
tests/002_hello.ts"
,
"--reload
"
])[
"total"
][
"calls"
]
[
deno_path
,
"
--reload"
,
"tests/002_hello.ts
"
])[
"total"
][
"calls"
]
syscall_count_map
[
"fetch_deps"
]
=
get_strace_summary
(
[
deno_path
,
"
tests/fetch_deps.ts"
,
"--reload
"
,
"
--allow-net
"
])[
"total"
][
"calls"
]
[
deno_path
,
"
--reload"
,
"--allow-net
"
,
"
tests/fetch_deps.ts
"
])[
"total"
][
"calls"
]
return
syscall_count_map
...
...
tools/fmt_test.py
浏览文件 @
780e72ab
...
...
@@ -19,7 +19,7 @@ def fmt_test(deno_exe):
# Set DENO_DIR to //js/ so we don't have to rely on an intenet
# connection to download https://deno.land/std/prettier/main.ts
deno_dir
=
os
.
path
.
join
(
root_path
,
"js"
)
run
([
deno_exe
,
dst
,
"--fmt"
],
merge_env
=
{
"DENO_DIR"
:
deno_dir
})
run
([
deno_exe
,
"fmt"
,
dst
],
merge_env
=
{
"DENO_DIR"
:
deno_dir
})
with
open
(
fixed_filename
)
as
f
:
expected
=
f
.
read
()
with
open
(
dst
)
as
f
:
...
...
tools/permission_prompt_test.py
浏览文件 @
780e72ab
...
...
@@ -69,14 +69,14 @@ class Prompt(object):
self
.
deno_exe
=
deno_exe
self
.
test_types
=
test_types
def
run
(
self
,
args
,
bytes_input
):
def
run
(
self
,
flags
,
args
,
bytes_input
):
"Returns (return_code, stdout, stderr)."
cmd
=
[
self
.
deno_exe
,
PERMISSIONS_PROMPT_TEST_TS
]
+
args
cmd
=
[
self
.
deno_exe
]
+
flags
+
[
PERMISSIONS_PROMPT_TEST_TS
]
+
args
return
tty_capture
(
cmd
,
bytes_input
)
def
warm_up
(
self
):
# ignore the ts compiling message
self
.
run
(
'needsWrite'
,
b
''
,
[
"--allow-write"
]
)
self
.
run
(
[
"--allow-write"
],
'needsWrite'
,
b
''
)
def
test
(
self
):
for
test_type
in
self
.
test_types
:
...
...
@@ -99,14 +99,14 @@ class Prompt(object):
def
test_allow_flag
(
self
,
test_type
):
code
,
stdout
,
stderr
=
self
.
run
(
[
"
needs"
+
test_type
.
capitalize
(),
"--allow-"
+
test_type
],
b
''
)
[
"
--allow-"
+
test_type
],
[
"needs"
+
test_type
.
capitalize
()
],
b
''
)
assert
code
==
0
assert
not
PROMPT_PATTERN
in
stderr
assert
not
FIRST_CHECK_FAILED_PATTERN
in
stdout
assert
not
PERMISSION_DENIED_PATTERN
in
stderr
def
test_yes_yes
(
self
,
test_type
):
code
,
stdout
,
stderr
=
self
.
run
([
"needs"
+
test_type
.
capitalize
()],
code
,
stdout
,
stderr
=
self
.
run
([
],
[
"needs"
+
test_type
.
capitalize
()],
b
'y
\n
y
\n
'
)
assert
code
==
0
assert
PROMPT_PATTERN
in
stderr
...
...
@@ -114,7 +114,7 @@ class Prompt(object):
assert
not
PERMISSION_DENIED_PATTERN
in
stderr
def
test_yes_no
(
self
,
test_type
):
code
,
stdout
,
stderr
=
self
.
run
([
"needs"
+
test_type
.
capitalize
()],
code
,
stdout
,
stderr
=
self
.
run
([
],
[
"needs"
+
test_type
.
capitalize
()],
b
'y
\n
n
\n
'
)
assert
code
==
1
assert
PROMPT_PATTERN
in
stderr
...
...
@@ -122,7 +122,7 @@ class Prompt(object):
assert
PERMISSION_DENIED_PATTERN
in
stderr
def
test_no_no
(
self
,
test_type
):
code
,
stdout
,
stderr
=
self
.
run
([
"needs"
+
test_type
.
capitalize
()],
code
,
stdout
,
stderr
=
self
.
run
([
],
[
"needs"
+
test_type
.
capitalize
()],
b
'n
\n
n
\n
'
)
assert
code
==
1
assert
PROMPT_PATTERN
in
stderr
...
...
@@ -130,7 +130,7 @@ class Prompt(object):
assert
PERMISSION_DENIED_PATTERN
in
stderr
def
test_no_yes
(
self
,
test_type
):
code
,
stdout
,
stderr
=
self
.
run
([
"needs"
+
test_type
.
capitalize
()],
code
,
stdout
,
stderr
=
self
.
run
([
],
[
"needs"
+
test_type
.
capitalize
()],
b
'n
\n
y
\n
'
)
assert
code
==
0
...
...
@@ -139,7 +139,7 @@ class Prompt(object):
assert
not
PERMISSION_DENIED_PATTERN
in
stderr
def
test_allow
(
self
,
test_type
):
code
,
stdout
,
stderr
=
self
.
run
([
"needs"
+
test_type
.
capitalize
()],
code
,
stdout
,
stderr
=
self
.
run
([
],
[
"needs"
+
test_type
.
capitalize
()],
b
'a
\n
'
)
assert
code
==
0
assert
PROMPT_PATTERN
in
stderr
...
...
@@ -147,7 +147,7 @@ class Prompt(object):
assert
not
PERMISSION_DENIED_PATTERN
in
stderr
def
test_deny
(
self
,
test_type
):
code
,
stdout
,
stderr
=
self
.
run
([
"needs"
+
test_type
.
capitalize
()],
code
,
stdout
,
stderr
=
self
.
run
([
],
[
"needs"
+
test_type
.
capitalize
()],
b
'd
\n
'
)
assert
code
==
1
assert
PROMPT_PATTERN
in
stderr
...
...
@@ -155,7 +155,7 @@ class Prompt(object):
assert
PERMISSION_DENIED_PATTERN
in
stderr
def
test_unrecognized_option
(
self
,
test_type
):
code
,
stdout
,
stderr
=
self
.
run
([
"needs"
+
test_type
.
capitalize
()],
code
,
stdout
,
stderr
=
self
.
run
([
],
[
"needs"
+
test_type
.
capitalize
()],
b
'e
\n
a
\n
'
)
assert
code
==
0
assert
PROMPT_PATTERN
in
stderr
...
...
@@ -165,17 +165,16 @@ class Prompt(object):
def
test_no_prompt
(
self
,
test_type
):
code
,
stdout
,
stderr
=
self
.
run
(
[
"
needs"
+
test_type
.
capitalize
(),
"--no-prompt"
],
b
''
)
[
"
--no-prompt"
],
[
"needs"
+
test_type
.
capitalize
()
],
b
''
)
assert
code
==
1
assert
not
PROMPT_PATTERN
in
stderr
assert
FIRST_CHECK_FAILED_PATTERN
in
stdout
assert
PERMISSION_DENIED_PATTERN
in
stderr
def
test_no_prompt_allow
(
self
,
test_type
):
code
,
stdout
,
stderr
=
self
.
run
([
"needs"
+
test_type
.
capitalize
(),
"--no-prompt"
,
"--allow-"
+
test_type
],
b
''
)
code
,
stdout
,
stderr
=
self
.
run
(
[
"--no-prompt"
,
"--allow-"
+
test_type
],
[
"needs"
+
test_type
.
capitalize
()],
b
''
)
assert
code
==
0
assert
not
PROMPT_PATTERN
in
stderr
assert
not
FIRST_CHECK_FAILED_PATTERN
in
stdout
...
...
tools/throughput_benchmark.py
浏览文件 @
780e72ab
...
...
@@ -19,7 +19,7 @@ ADDR = "127.0.0.1:4544"
def
cat
(
deno_exe
,
megs
):
size
=
megs
*
MB
start
=
time
.
time
()
cmd
=
deno_exe
+
"
tests/cat.ts --allow-read
/dev/zero | head -c %s "
%
size
cmd
=
deno_exe
+
"
--allow-read tests/cat.ts
/dev/zero | head -c %s "
%
size
print
cmd
subprocess
.
check_output
(
cmd
,
shell
=
True
)
end
=
time
.
time
()
...
...
tools/unit_tests.py
浏览文件 @
780e72ab
...
...
@@ -32,7 +32,7 @@ def run_unit_test2(cmd):
def
run_unit_test
(
deno_exe
,
permStr
,
flags
=
None
):
if
flags
is
None
:
flags
=
[]
cmd
=
[
deno_exe
,
"js/unit_tests.ts"
,
permStr
]
+
flags
cmd
=
[
deno_exe
,
"js/unit_tests.ts"
]
+
flags
+
[
permStr
]
run_unit_test2
(
cmd
)
...
...
website/manual.md
浏览文件 @
780e72ab
...
...
@@ -67,10 +67,12 @@ Deno provides <a href="https://github.com/denoland/deno_std">a set of reviewed
-
Be able to serve HTTP efficiently.
(
[
Currently it is relatively slow.
](
https://deno.land/benchmarks.html#req-per-sec
)
)
-
Provide useful tooling out of the box: Built-in command-line debugger
[
not yet
](
https://github.com/denoland/deno/issues/1120
)
, built-in lint
[
not yet
](
https://github.com/denoland/deno/issues/1880
)
, dependency inspector
(
`deno --info`
), built-in code formatter (
`deno --fmt`
),
-
Provide useful tooling out of the box:
-
command-line debugger
[
not yet
](
https://github.com/denoland/deno/issues/1120
)
-
linter
[
not yet
](
https://github.com/denoland/deno/issues/1880
)
-
dependency inspector (
`deno info`
)
-
code formatter (
`deno fmt`
),
### Non-goals
...
...
@@ -533,29 +535,38 @@ if (import.meta.main) {
```
shellsession
$ deno -h
Usage: deno script.ts
Options:
--allow-read Allow file system read access
--allow-write Allow file system write access
--allow-net Allow network access
--allow-env Allow environment access
--allow-run Allow running subprocesses
-A, --allow-all Allow all permissions
--no-prompt Do not use prompts
-h, --help Print this message
-D, --log-debug Log debug output
-v, --version Print the version
-r, --reload Reload source code cache (recompile TypeScript)
--v8-options Print V8 command line options
--types Print runtime TypeScript declarations
--prefetch Prefetch the dependencies
--info Show source file related info
--fmt Format code
Environment variables:
DENO_DIR Set deno's base directory
NO_COLOR Set to disable color
deno
USAGE:
deno_dev [FLAGS] [OPTIONS] [SUBCOMMAND]
FLAGS:
-A, --allow-all Allow all permissions
--allow-env Allow environment access
--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
--prefetch Prefetch the dependencies
-r, --reload Reload source code cache (recompile TypeScript)
--types Print runtime TypeScript declarations
--v8-options Print V8 command line options
-v, --version Print the version
OPTIONS:
--v8-flags=<v8-flags> Set V8 command line options
SUBCOMMANDS:
<script> Script to run
fmt Format files
info Show source file related info
ENVIRONMENT VARIABLES:
DENO_DIR Set deno's base directory
NO_COLOR Set to disable color
```
### Environmental variables
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录