summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2019-05-03 23:15:16 +0200
committerRyan Dahl <ry@tinyclouds.org>2019-05-03 17:15:16 -0400
commitf6a9d7d7172df6422f895dcfe6f4267ad1b472da (patch)
tree086a9e3e75e7597f2d456c26749d9d9d64e51990
parent36081171323e266760db8bed2f31a6e3be7d8839 (diff)
add "deno run" subcommand (#2215)
-rw-r--r--cli/flags.rs371
-rw-r--r--cli/main.rs1
-rw-r--r--tests/001_hello.test2
-rw-r--r--tests/002_hello.test2
-rw-r--r--tests/003_relative_import.test2
-rw-r--r--tests/004_set_timeout.test2
-rw-r--r--tests/005_more_imports.test2
-rw-r--r--tests/006_url_imports.test2
-rw-r--r--tests/012_async.test2
-rw-r--r--tests/016_double_await.test2
-rw-r--r--tests/017_import_redirect.test2
-rw-r--r--tests/018_async_catch.test2
-rw-r--r--tests/019_media_types.test2
-rw-r--r--tests/020_json_modules.test2
-rw-r--r--tests/021_mjs_modules.test2
-rw-r--r--tests/023_no_ext_with_headers.test2
-rw-r--r--tests/024_import_no_ext_with_headers.test2
-rw-r--r--tests/025_high_precision.test2
-rw-r--r--tests/025_reload_js_type_error.test2
-rw-r--r--tests/026_redirect_javascript.js.test2
-rw-r--r--tests/026_workers.test2
-rw-r--r--tests/027_redirect_typescript.ts.test2
-rw-r--r--tests/028_args.test2
-rw-r--r--tests/async_error.test2
-rw-r--r--tests/circular1.test2
-rw-r--r--tests/config.test2
-rw-r--r--tests/error_001.test2
-rw-r--r--tests/error_002.test2
-rw-r--r--tests/error_003_typescript.test2
-rw-r--r--tests/error_004_missing_module.test2
-rw-r--r--tests/error_005_missing_dynamic_import.test2
-rw-r--r--tests/error_006_import_ext_failure.test2
-rw-r--r--tests/error_007_any.test2
-rw-r--r--tests/error_008_checkjs.test2
-rw-r--r--tests/error_syntax.test2
-rw-r--r--tests/exit_error42.test2
-rw-r--r--tests/https_import.test2
-rw-r--r--tests/if_main.test2
-rw-r--r--tests/import_meta.test2
-rw-r--r--tests/unbuffered_stderr.test2
-rw-r--r--tests/unbuffered_stdout.test2
-rw-r--r--tests/v8_flags.test2
-rw-r--r--tests/wasm.test4
-rwxr-xr-xtools/benchmark.py7
-rwxr-xr-xtools/deno_dir_test.py2
-rwxr-xr-xtools/http_benchmark.py4
-rwxr-xr-xtools/is_tty_test.py2
-rwxr-xr-xtools/permission_prompt_test.py3
-rw-r--r--tools/repl_test.py2
-rwxr-xr-xtools/test.py6
-rwxr-xr-xtools/throughput_benchmark.py5
-rwxr-xr-xtools/unit_tests.py2
-rw-r--r--website/index.html2
-rw-r--r--website/manual.md33
54 files changed, 314 insertions, 210 deletions
diff --git a/cli/flags.rs b/cli/flags.rs
index f60c1a3fa..6e690645b 100644
--- a/cli/flags.rs
+++ b/cli/flags.rs
@@ -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::Run);
- assert_eq!(argv, svec!["deno", "version"]);
+ assert_eq!(subcommand, DenoSubcommand::Version);
+ 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::Repl);
- assert_eq!(argv, svec!["deno"]);
+ assert_eq!(subcommand, DenoSubcommand::Run);
+ 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::Repl);
- assert_eq!(argv, svec!["deno"]);
+ assert_eq!(subcommand, DenoSubcommand::Run);
+ 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()
- }
- )
- }
}
diff --git a/cli/main.rs b/cli/main.rs
index 5a6efa073..8bef2d2ff 100644
--- a/cli/main.rs
+++ b/cli/main.rs
@@ -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),
}
}
diff --git a/tests/001_hello.test b/tests/001_hello.test
index 121dbb2ea..27cc21f33 100644
--- a/tests/001_hello.test
+++ b/tests/001_hello.test
@@ -1,2 +1,2 @@
-args: --reload tests/001_hello.js
+args: run --reload tests/001_hello.js
output: tests/001_hello.js.out
diff --git a/tests/002_hello.test b/tests/002_hello.test
index d889acd00..412b2ac79 100644
--- a/tests/002_hello.test
+++ b/tests/002_hello.test
@@ -1,2 +1,2 @@
-args: --reload tests/002_hello.ts
+args: run --reload tests/002_hello.ts
output: tests/002_hello.ts.out
diff --git a/tests/003_relative_import.test b/tests/003_relative_import.test
index 5206c1aaa..0f69633e0 100644
--- a/tests/003_relative_import.test
+++ b/tests/003_relative_import.test
@@ -1,2 +1,2 @@
-args: --reload tests/003_relative_import.ts
+args: run --reload tests/003_relative_import.ts
output: tests/003_relative_import.ts.out
diff --git a/tests/004_set_timeout.test b/tests/004_set_timeout.test
index 6fda34f25..e4a534f48 100644
--- a/tests/004_set_timeout.test
+++ b/tests/004_set_timeout.test
@@ -1,2 +1,2 @@
-args: --reload tests/004_set_timeout.ts
+args: run --reload tests/004_set_timeout.ts
output: tests/004_set_timeout.ts.out
diff --git a/tests/005_more_imports.test b/tests/005_more_imports.test
index fde5276fe..3bc2e999d 100644
--- a/tests/005_more_imports.test
+++ b/tests/005_more_imports.test
@@ -1,2 +1,2 @@
-args: --reload tests/005_more_imports.ts
+args: run --reload tests/005_more_imports.ts
output: tests/005_more_imports.ts.out
diff --git a/tests/006_url_imports.test b/tests/006_url_imports.test
index 13c04219a..28d9116f7 100644
--- a/tests/006_url_imports.test
+++ b/tests/006_url_imports.test
@@ -1,2 +1,2 @@
-args: --reload tests/006_url_imports.ts
+args: run --reload tests/006_url_imports.ts
output: tests/006_url_imports.ts.out
diff --git a/tests/012_async.test b/tests/012_async.test
index 3694d7362..63a0e0d23 100644
--- a/tests/012_async.test
+++ b/tests/012_async.test
@@ -1,2 +1,2 @@
-args: --reload tests/012_async.ts
+args: run --reload tests/012_async.ts
output: tests/012_async.ts.out
diff --git a/tests/016_double_await.test b/tests/016_double_await.test
index 842d167cc..a1448e5a1 100644
--- a/tests/016_double_await.test
+++ b/tests/016_double_await.test
@@ -1,2 +1,2 @@
-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
diff --git a/tests/017_import_redirect.test b/tests/017_import_redirect.test
index db7439f05..d8e7570db 100644
--- a/tests/017_import_redirect.test
+++ b/tests/017_import_redirect.test
@@ -1,2 +1,2 @@
-args: --reload tests/017_import_redirect.ts
+args: run --reload tests/017_import_redirect.ts
output: tests/017_import_redirect.ts.out
diff --git a/tests/018_async_catch.test b/tests/018_async_catch.test
index 08961916d..ee62836ab 100644
--- a/tests/018_async_catch.test
+++ b/tests/018_async_catch.test
@@ -1,2 +1,2 @@
-args: --reload tests/018_async_catch.ts
+args: run --reload tests/018_async_catch.ts
output: tests/018_async_catch.ts.out
diff --git a/tests/019_media_types.test b/tests/019_media_types.test
index c0fea5bc6..d311abc10 100644
--- a/tests/019_media_types.test
+++ b/tests/019_media_types.test
@@ -1,2 +1,2 @@
-args: --reload tests/019_media_types.ts
+args: run --reload tests/019_media_types.ts
output: tests/019_media_types.ts.out
diff --git a/tests/020_json_modules.test b/tests/020_json_modules.test
index cacd21da0..624d69db3 100644
--- a/tests/020_json_modules.test
+++ b/tests/020_json_modules.test
@@ -1,2 +1,2 @@
-args: --reload tests/020_json_modules.ts
+args: run --reload tests/020_json_modules.ts
output: tests/020_json_modules.ts.out
diff --git a/tests/021_mjs_modules.test b/tests/021_mjs_modules.test
index 9b60b9d97..b74554fb1 100644
--- a/tests/021_mjs_modules.test
+++ b/tests/021_mjs_modules.test
@@ -1,2 +1,2 @@
-args: --reload tests/021_mjs_modules.ts
+args: run --reload tests/021_mjs_modules.ts
output: tests/021_mjs_modules.ts.out
diff --git a/tests/023_no_ext_with_headers.test b/tests/023_no_ext_with_headers.test
index b663f174c..cbab7cabd 100644
--- a/tests/023_no_ext_with_headers.test
+++ b/tests/023_no_ext_with_headers.test
@@ -1,2 +1,2 @@
-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
diff --git a/tests/024_import_no_ext_with_headers.test b/tests/024_import_no_ext_with_headers.test
index efaca96c3..e76a9d5ac 100644
--- a/tests/024_import_no_ext_with_headers.test
+++ b/tests/024_import_no_ext_with_headers.test
@@ -1,2 +1,2 @@
-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
diff --git a/tests/025_high_precision.test b/tests/025_high_precision.test
index 2bc460c9b..fbdbbe8f9 100644
--- a/tests/025_high_precision.test
+++ b/tests/025_high_precision.test
@@ -1,2 +1,2 @@
-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
diff --git a/tests/025_reload_js_type_error.test b/tests/025_reload_js_type_error.test
index a2cd214be..d88c1c578 100644
--- a/tests/025_reload_js_type_error.test
+++ b/tests/025_reload_js_type_error.test
@@ -1,2 +1,2 @@
-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
diff --git a/tests/026_redirect_javascript.js.test b/tests/026_redirect_javascript.js.test
index 81d0ad038..2b1f0d522 100644
--- a/tests/026_redirect_javascript.js.test
+++ b/tests/026_redirect_javascript.js.test
@@ -1,2 +1,2 @@
-args: --reload tests/026_redirect_javascript.js
+args: run --reload tests/026_redirect_javascript.js
output: tests/026_redirect_javascript.js.out
diff --git a/tests/026_workers.test b/tests/026_workers.test
index 5019a9256..1d973a6c5 100644
--- a/tests/026_workers.test
+++ b/tests/026_workers.test
@@ -1,2 +1,2 @@
-args: --reload tests/026_workers.ts
+args: run --reload tests/026_workers.ts
output: tests/026_workers.ts.out
diff --git a/tests/027_redirect_typescript.ts.test b/tests/027_redirect_typescript.ts.test
index 8762e61f2..ba2525ff6 100644
--- a/tests/027_redirect_typescript.ts.test
+++ b/tests/027_redirect_typescript.ts.test
@@ -1,2 +1,2 @@
-args: --reload tests/027_redirect_typescript.ts
+args: run --reload tests/027_redirect_typescript.ts
output: tests/027_redirect_typescript.ts.out
diff --git a/tests/028_args.test b/tests/028_args.test
index df3c56205..af98c8b7a 100644
--- a/tests/028_args.test
+++ b/tests/028_args.test
@@ -1,2 +1,2 @@
-args: --reload tests/028_args.ts --arg1 val1 --arg2=val2 -- arg3 arg4
+args: run --reload tests/028_args.ts --arg1 val1 --arg2=val2 -- arg3 arg4
output: tests/028_args.ts.out
diff --git a/tests/async_error.test b/tests/async_error.test
index 8ebbfb56c..2cc8de922 100644
--- a/tests/async_error.test
+++ b/tests/async_error.test
@@ -1,4 +1,4 @@
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
diff --git a/tests/circular1.test b/tests/circular1.test
index d86a00c31..80afb035b 100644
--- a/tests/circular1.test
+++ b/tests/circular1.test
@@ -1,2 +1,2 @@
-args: tests/circular1.js --reload
+args: run --reload tests/circular1.js
output: tests/circular1.js.out
diff --git a/tests/config.test b/tests/config.test
index ee811ab8b..d8c5fde99 100644
--- a/tests/config.test
+++ b/tests/config.test
@@ -1,4 +1,4 @@
-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
diff --git a/tests/error_001.test b/tests/error_001.test
index ca0a2ef2e..df1ee5f4a 100644
--- a/tests/error_001.test
+++ b/tests/error_001.test
@@ -1,4 +1,4 @@
-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
diff --git a/tests/error_002.test b/tests/error_002.test
index 12f6e3cec..d2954506d 100644
--- a/tests/error_002.test
+++ b/tests/error_002.test
@@ -1,4 +1,4 @@
-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
diff --git a/tests/error_003_typescript.test b/tests/error_003_typescript.test
index 7a9d4a8ea..f721829a2 100644
--- a/tests/error_003_typescript.test
+++ b/tests/error_003_typescript.test
@@ -1,3 +1,3 @@
-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
diff --git a/tests/error_004_missing_module.test b/tests/error_004_missing_module.test
index b94c86004..99c25908c 100644
--- a/tests/error_004_missing_module.test
+++ b/tests/error_004_missing_module.test
@@ -1,4 +1,4 @@
-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
diff --git a/tests/error_005_missing_dynamic_import.test b/tests/error_005_missing_dynamic_import.test
index 2acf467c1..ffbf20be9 100644
--- a/tests/error_005_missing_dynamic_import.test
+++ b/tests/error_005_missing_dynamic_import.test
@@ -1,4 +1,4 @@
-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
diff --git a/tests/error_006_import_ext_failure.test b/tests/error_006_import_ext_failure.test
index 5fe245739..59a82a364 100644
--- a/tests/error_006_import_ext_failure.test
+++ b/tests/error_006_import_ext_failure.test
@@ -1,4 +1,4 @@
-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
diff --git a/tests/error_007_any.test b/tests/error_007_any.test
index fc0480796..a9f99052a 100644
--- a/tests/error_007_any.test
+++ b/tests/error_007_any.test
@@ -1,4 +1,4 @@
-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
diff --git a/tests/error_008_checkjs.test b/tests/error_008_checkjs.test
index 1944f0bca..ae3a5414a 100644
--- a/tests/error_008_checkjs.test
+++ b/tests/error_008_checkjs.test
@@ -1,4 +1,4 @@
-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
diff --git a/tests/error_syntax.test b/tests/error_syntax.test
index e83cd030f..922226112 100644
--- a/tests/error_syntax.test
+++ b/tests/error_syntax.test
@@ -1,4 +1,4 @@
-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
diff --git a/tests/exit_error42.test b/tests/exit_error42.test
index 21a339a5e..e2c196f6f 100644
--- a/tests/exit_error42.test
+++ b/tests/exit_error42.test
@@ -1,3 +1,3 @@
exit_code: 42
-args: --reload tests/exit_error42.ts
+args: run --reload tests/exit_error42.ts
output: tests/exit_error42.ts.out
diff --git a/tests/https_import.test b/tests/https_import.test
index 6cfb53058..1235548da 100644
--- a/tests/https_import.test
+++ b/tests/https_import.test
@@ -1,2 +1,2 @@
-args: --reload tests/https_import.ts
+args: run --reload tests/https_import.ts
output: tests/https_import.ts.out
diff --git a/tests/if_main.test b/tests/if_main.test
index fe4f061a6..c72c89866 100644
--- a/tests/if_main.test
+++ b/tests/if_main.test
@@ -1,2 +1,2 @@
-args: --reload tests/if_main.ts
+args: run --reload tests/if_main.ts
output: tests/if_main.ts.out
diff --git a/tests/import_meta.test b/tests/import_meta.test
index bfef5cb56..d38f2d939 100644
--- a/tests/import_meta.test
+++ b/tests/import_meta.test
@@ -1,2 +1,2 @@
-args: --reload tests/import_meta.ts
+args: run --reload tests/import_meta.ts
output: tests/import_meta.ts.out
diff --git a/tests/unbuffered_stderr.test b/tests/unbuffered_stderr.test
index b3909dc2d..366c1c445 100644
--- a/tests/unbuffered_stderr.test
+++ b/tests/unbuffered_stderr.test
@@ -1,3 +1,3 @@
-args: --reload tests/unbuffered_stderr.ts
+args: run --reload tests/unbuffered_stderr.ts
check_stderr: true
output: tests/unbuffered_stderr.ts.out
diff --git a/tests/unbuffered_stdout.test b/tests/unbuffered_stdout.test
index 3ed399cb8..7caa05708 100644
--- a/tests/unbuffered_stdout.test
+++ b/tests/unbuffered_stdout.test
@@ -1,2 +1,2 @@
-args: --reload tests/unbuffered_stdout.ts
+args: run --reload tests/unbuffered_stdout.ts
output: tests/unbuffered_stdout.ts.out
diff --git a/tests/v8_flags.test b/tests/v8_flags.test
index 66d129bd1..50e00be02 100644
--- a/tests/v8_flags.test
+++ b/tests/v8_flags.test
@@ -1,2 +1,2 @@
-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
diff --git a/tests/wasm.test b/tests/wasm.test
index 9e3ecbb28..c4c399670 100644
--- a/tests/wasm.test
+++ b/tests/wasm.test
@@ -1,2 +1,2 @@
-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
diff --git a/tools/benchmark.py b/tools/benchmark.py
index 55e919643..03fcc497e 100755
--- a/tools/benchmark.py
+++ b/tools/benchmark.py
@@ -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 = {}
diff --git a/tools/deno_dir_test.py b/tools/deno_dir_test.py
index 4b6c3d8aa..bcfa370bf 100755
--- a/tools/deno_dir_test.py
+++ b/tools/deno_dir_test.py
@@ -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)
diff --git a/tools/http_benchmark.py b/tools/http_benchmark.py
index 7db900a86..68d68e44a 100755
--- a/tools/http_benchmark.py
+++ b/tools/http_benchmark.py
@@ -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."
diff --git a/tools/is_tty_test.py b/tools/is_tty_test.py
index 867fd7a1c..6f7509a8c 100755
--- a/tools/is_tty_test.py
+++ b/tools/is_tty_test.py
@@ -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
diff --git a/tools/permission_prompt_test.py b/tools/permission_prompt_test.py
index 6e8922640..e3ee7d9c8 100755
--- a/tools/permission_prompt_test.py
+++ b/tools/permission_prompt_test.py
@@ -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):
diff --git a/tools/repl_test.py b/tools/repl_test.py
index 59346d3e8..9ea1b82af 100644
--- a/tools/repl_test.py
+++ b/tools/repl_test.py
@@ -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_)
diff --git a/tools/test.py b/tools/test.py
index e4914ae50..2a59a0c87 100755
--- a/tools/test.py
+++ b/tools/test.py
@@ -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()
diff --git a/tools/throughput_benchmark.py b/tools/throughput_benchmark.py
index 712edfe43..9343d9613 100755
--- a/tools/throughput_benchmark.py
+++ b/tools/throughput_benchmark.py
@@ -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:
diff --git a/tools/unit_tests.py b/tools/unit_tests.py
index abc9baf06..14284b325 100755
--- a/tools/unit_tests.py
+++ b/tools/unit_tests.py
@@ -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)
diff --git a/website/index.html b/website/index.html
index f1cbde49f..4af6d67a4 100644
--- a/website/index.html
+++ b/website/index.html
@@ -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>
diff --git a/website/manual.md b/website/manual.md
index bfc8f9603..efa867b18 100644
--- a/website/manual.md
+++ b/website/manual.md
@@ -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
- fetch Fetch the dependencies
- 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
+ fmt Format files
+ 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