mirror of
https://github.com/denoland/deno.git
synced 2024-12-01 16:51:13 -05:00
BREAKING: remove CLI 'deno script.ts' hack (#5026)
This PR removes the hack in CLI that allows to run scripts with shorthand: deno script.ts. Removing this functionality because it hacks around short-comings of clap our CLI parser. We agree that this shorthand syntax is desirable, but it needs to be rethinked and reimplemented. For 1.0 we should go with conservative approach that is correct.
This commit is contained in:
parent
bd3b9cc7d9
commit
a913b7a1ba
14 changed files with 66 additions and 177 deletions
158
cli/flags.rs
158
cli/flags.rs
|
@ -6,7 +6,6 @@ use clap::Arg;
|
||||||
use clap::ArgMatches;
|
use clap::ArgMatches;
|
||||||
use clap::SubCommand;
|
use clap::SubCommand;
|
||||||
use log::Level;
|
use log::Level;
|
||||||
use std::collections::HashSet;
|
|
||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
|
@ -14,14 +13,6 @@ use std::path::{Path, PathBuf};
|
||||||
macro_rules! svec {
|
macro_rules! svec {
|
||||||
($($x:expr),*) => (vec![$($x.to_string()),*]);
|
($($x:expr),*) => (vec![$($x.to_string()),*]);
|
||||||
}
|
}
|
||||||
/// Creates HashSet<String> from string literals
|
|
||||||
macro_rules! sset {
|
|
||||||
($($x:expr),*) => {{
|
|
||||||
let _v = svec![$($x.to_string()),*];
|
|
||||||
let hash_set: HashSet<String> = _v.iter().cloned().collect();
|
|
||||||
hash_set
|
|
||||||
}}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
pub enum DenoSubcommand {
|
pub enum DenoSubcommand {
|
||||||
|
@ -196,17 +187,15 @@ Docs: https://deno.land/std/manual.md
|
||||||
Modules: https://deno.land/std/ https://deno.land/x/
|
Modules: https://deno.land/std/ https://deno.land/x/
|
||||||
Bugs: https://github.com/denoland/deno/issues
|
Bugs: https://github.com/denoland/deno/issues
|
||||||
|
|
||||||
To start the REPL, supply no arguments:
|
To start the REPL:
|
||||||
deno
|
deno
|
||||||
|
|
||||||
To execute a script:
|
To execute a script:
|
||||||
deno run https://deno.land/std/examples/welcome.ts
|
deno run https://deno.land/std/examples/welcome.ts
|
||||||
deno https://deno.land/std/examples/welcome.ts
|
|
||||||
|
|
||||||
To evaluate code in the shell:
|
To evaluate code in the shell:
|
||||||
deno eval \"console.log(30933 + 404)\"
|
deno eval \"console.log(30933 + 404)\"
|
||||||
|
";
|
||||||
Run 'deno help run' for 'run'-specific flags.";
|
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
static ref LONG_VERSION: String = format!(
|
static ref LONG_VERSION: String = format!(
|
||||||
|
@ -228,7 +217,6 @@ pub fn flags_from_vec(args: Vec<String>) -> Flags {
|
||||||
|
|
||||||
/// Same as flags_from_vec but does not exit on error.
|
/// Same as flags_from_vec but does not exit on error.
|
||||||
pub fn flags_from_vec_safe(args: Vec<String>) -> clap::Result<Flags> {
|
pub fn flags_from_vec_safe(args: Vec<String>) -> clap::Result<Flags> {
|
||||||
let args = arg_hacks(args);
|
|
||||||
let app = clap_root();
|
let app = clap_root();
|
||||||
let matches = app.get_matches_from_safe(args)?;
|
let matches = app.get_matches_from_safe(args)?;
|
||||||
|
|
||||||
|
@ -272,7 +260,7 @@ pub fn flags_from_vec_safe(args: Vec<String>) -> clap::Result<Flags> {
|
||||||
} else if let Some(m) = matches.subcommand_matches("doc") {
|
} else if let Some(m) = matches.subcommand_matches("doc") {
|
||||||
doc_parse(&mut flags, m);
|
doc_parse(&mut flags, m);
|
||||||
} else {
|
} else {
|
||||||
unimplemented!();
|
repl_parse(&mut flags, &matches);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(flags)
|
Ok(flags)
|
||||||
|
@ -1342,79 +1330,11 @@ fn resolve_hosts(paths: Vec<String>) -> Vec<String> {
|
||||||
out
|
out
|
||||||
}
|
}
|
||||||
|
|
||||||
fn arg_hacks(mut args: Vec<String>) -> Vec<String> {
|
|
||||||
// Hack #1 We want to default the subcommand to "run"
|
|
||||||
// Clap does not let us have a default sub-command. But we want to allow users
|
|
||||||
// to do "deno script.js" instead of "deno run script.js".
|
|
||||||
// This function insert the "run" into the second position of the args.
|
|
||||||
assert!(!args.is_empty());
|
|
||||||
// Rational:
|
|
||||||
// deno -> deno repl
|
|
||||||
if args.len() == 1 {
|
|
||||||
args.insert(1, "repl".to_string());
|
|
||||||
return args;
|
|
||||||
}
|
|
||||||
let subcommands = sset![
|
|
||||||
"bundle",
|
|
||||||
"completions",
|
|
||||||
"doc",
|
|
||||||
"eval",
|
|
||||||
"cache",
|
|
||||||
"fmt",
|
|
||||||
"test",
|
|
||||||
"info",
|
|
||||||
"repl",
|
|
||||||
"run",
|
|
||||||
"types",
|
|
||||||
"install",
|
|
||||||
"help",
|
|
||||||
"version",
|
|
||||||
"upgrade"
|
|
||||||
];
|
|
||||||
let modifier_flags = sset!["-h", "--help", "-V", "--version"];
|
|
||||||
// deno [subcommand|behavior modifier flags] -> do nothing
|
|
||||||
if subcommands.contains(&args[1]) || modifier_flags.contains(&args[1]) {
|
|
||||||
return args;
|
|
||||||
}
|
|
||||||
// This is not perfect either, since originally we should also
|
|
||||||
// support e.g. `-L debug` which `debug` would be treated as main module.
|
|
||||||
// Instead `-L=debug` must be used
|
|
||||||
let mut has_main_module = false;
|
|
||||||
for arg in args.iter().skip(1) {
|
|
||||||
if !arg.starts_with('-') {
|
|
||||||
has_main_module = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if has_main_module {
|
|
||||||
// deno ...-[flags] NAME ... -> deno run ...-[flags] NAME ...
|
|
||||||
args.insert(1, "run".to_string());
|
|
||||||
} else {
|
|
||||||
// deno ...-[flags] -> deno repl ...-[flags]
|
|
||||||
args.insert(1, "repl".to_string());
|
|
||||||
}
|
|
||||||
args
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use std::env::current_dir;
|
use std::env::current_dir;
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn arg_hacks_test() {
|
|
||||||
let args0 = arg_hacks(svec!["deno", "--version"]);
|
|
||||||
assert_eq!(args0, ["deno", "--version"]);
|
|
||||||
let args1 = arg_hacks(svec!["deno"]);
|
|
||||||
assert_eq!(args1, ["deno", "repl"]);
|
|
||||||
let args2 = arg_hacks(svec!["deno", "-L=debug", "-h"]);
|
|
||||||
assert_eq!(args2, ["deno", "repl", "-L=debug", "-h"]);
|
|
||||||
let args3 = arg_hacks(svec!["deno", "script.js"]);
|
|
||||||
assert_eq!(args3, ["deno", "run", "script.js"]);
|
|
||||||
let args4 = arg_hacks(svec!["deno", "-A", "script.js", "-L=info"]);
|
|
||||||
assert_eq!(args4, ["deno", "run", "-A", "script.js", "-L=info"]);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn upgrade() {
|
fn upgrade() {
|
||||||
let r =
|
let r =
|
||||||
|
@ -1967,41 +1887,6 @@ mod tests {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn default_to_run() {
|
|
||||||
let r = flags_from_vec_safe(svec!["deno", "script.ts"]);
|
|
||||||
assert_eq!(
|
|
||||||
r.unwrap(),
|
|
||||||
Flags {
|
|
||||||
subcommand: DenoSubcommand::Run {
|
|
||||||
script: "script.ts".to_string(),
|
|
||||||
},
|
|
||||||
..Flags::default()
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn default_to_run_with_permissions() {
|
|
||||||
let r = flags_from_vec_safe(svec![
|
|
||||||
"deno",
|
|
||||||
"--allow-net",
|
|
||||||
"--allow-read",
|
|
||||||
"script.ts"
|
|
||||||
]);
|
|
||||||
assert_eq!(
|
|
||||||
r.unwrap(),
|
|
||||||
Flags {
|
|
||||||
subcommand: DenoSubcommand::Run {
|
|
||||||
script: "script.ts".to_string(),
|
|
||||||
},
|
|
||||||
allow_net: true,
|
|
||||||
allow_read: true,
|
|
||||||
..Flags::default()
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn bundle() {
|
fn bundle() {
|
||||||
let r = flags_from_vec_safe(svec!["deno", "bundle", "source.ts"]);
|
let r = flags_from_vec_safe(svec!["deno", "bundle", "source.ts"]);
|
||||||
|
@ -2071,25 +1956,6 @@ mod tests {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn default_to_run_importmap() {
|
|
||||||
let r = flags_from_vec_safe(svec![
|
|
||||||
"deno",
|
|
||||||
"--importmap=importmap.json",
|
|
||||||
"script.ts"
|
|
||||||
]);
|
|
||||||
assert_eq!(
|
|
||||||
r.unwrap(),
|
|
||||||
Flags {
|
|
||||||
subcommand: DenoSubcommand::Run {
|
|
||||||
script: "script.ts".to_string(),
|
|
||||||
},
|
|
||||||
import_map_path: Some("importmap.json".to_owned()),
|
|
||||||
..Flags::default()
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn cache_importmap() {
|
fn cache_importmap() {
|
||||||
let r = flags_from_vec_safe(svec![
|
let r = flags_from_vec_safe(svec![
|
||||||
|
@ -2250,8 +2116,12 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn log_level() {
|
fn log_level() {
|
||||||
let r =
|
let r = flags_from_vec_safe(svec![
|
||||||
flags_from_vec_safe(svec!["deno", "--log-level=debug", "script.ts"]);
|
"deno",
|
||||||
|
"run",
|
||||||
|
"--log-level=debug",
|
||||||
|
"script.ts"
|
||||||
|
]);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
r.unwrap(),
|
r.unwrap(),
|
||||||
Flags {
|
Flags {
|
||||||
|
@ -2266,7 +2136,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn quiet() {
|
fn quiet() {
|
||||||
let r = flags_from_vec_safe(svec!["deno", "-q", "script.ts"]);
|
let r = flags_from_vec_safe(svec!["deno", "run", "-q", "script.ts"]);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
r.unwrap(),
|
r.unwrap(),
|
||||||
Flags {
|
Flags {
|
||||||
|
@ -2350,7 +2220,8 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn no_remote() {
|
fn no_remote() {
|
||||||
let r = flags_from_vec_safe(svec!["deno", "--no-remote", "script.ts"]);
|
let r =
|
||||||
|
flags_from_vec_safe(svec!["deno", "run", "--no-remote", "script.ts"]);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
r.unwrap(),
|
r.unwrap(),
|
||||||
Flags {
|
Flags {
|
||||||
|
@ -2365,7 +2236,8 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn cached_only() {
|
fn cached_only() {
|
||||||
let r = flags_from_vec_safe(svec!["deno", "--cached-only", "script.ts"]);
|
let r =
|
||||||
|
flags_from_vec_safe(svec!["deno", "run", "--cached-only", "script.ts"]);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
r.unwrap(),
|
r.unwrap(),
|
||||||
Flags {
|
Flags {
|
||||||
|
@ -2382,6 +2254,7 @@ mod tests {
|
||||||
fn allow_net_whitelist_with_ports() {
|
fn allow_net_whitelist_with_ports() {
|
||||||
let r = flags_from_vec_safe(svec![
|
let r = flags_from_vec_safe(svec![
|
||||||
"deno",
|
"deno",
|
||||||
|
"run",
|
||||||
"--allow-net=deno.land,:8000,:4545",
|
"--allow-net=deno.land,:8000,:4545",
|
||||||
"script.ts"
|
"script.ts"
|
||||||
]);
|
]);
|
||||||
|
@ -2409,6 +2282,7 @@ mod tests {
|
||||||
fn lock_write() {
|
fn lock_write() {
|
||||||
let r = flags_from_vec_safe(svec![
|
let r = flags_from_vec_safe(svec![
|
||||||
"deno",
|
"deno",
|
||||||
|
"run",
|
||||||
"--lock-write",
|
"--lock-write",
|
||||||
"--lock=lock.json",
|
"--lock=lock.json",
|
||||||
"script.ts"
|
"script.ts"
|
||||||
|
|
|
@ -1322,7 +1322,7 @@ itest!(error_014_catch_dynamic_import_error {
|
||||||
});
|
});
|
||||||
|
|
||||||
itest!(error_015_dynamic_import_permissions {
|
itest!(error_015_dynamic_import_permissions {
|
||||||
args: "--reload error_015_dynamic_import_permissions.js",
|
args: "run --reload error_015_dynamic_import_permissions.js",
|
||||||
output: "error_015_dynamic_import_permissions.out",
|
output: "error_015_dynamic_import_permissions.out",
|
||||||
check_stderr: true,
|
check_stderr: true,
|
||||||
exit_code: 1,
|
exit_code: 1,
|
||||||
|
@ -1331,7 +1331,7 @@ itest!(error_015_dynamic_import_permissions {
|
||||||
|
|
||||||
// We have an allow-net flag but not allow-read, it should still result in error.
|
// We have an allow-net flag but not allow-read, it should still result in error.
|
||||||
itest!(error_016_dynamic_import_permissions2 {
|
itest!(error_016_dynamic_import_permissions2 {
|
||||||
args: "--reload --allow-net error_016_dynamic_import_permissions2.js",
|
args: "run --reload --allow-net error_016_dynamic_import_permissions2.js",
|
||||||
output: "error_016_dynamic_import_permissions2.out",
|
output: "error_016_dynamic_import_permissions2.out",
|
||||||
check_stderr: true,
|
check_stderr: true,
|
||||||
exit_code: 1,
|
exit_code: 1,
|
||||||
|
@ -1339,63 +1339,63 @@ itest!(error_016_dynamic_import_permissions2 {
|
||||||
});
|
});
|
||||||
|
|
||||||
itest!(error_017_hide_long_source_ts {
|
itest!(error_017_hide_long_source_ts {
|
||||||
args: "--reload error_017_hide_long_source_ts.ts",
|
args: "run --reload error_017_hide_long_source_ts.ts",
|
||||||
output: "error_017_hide_long_source_ts.ts.out",
|
output: "error_017_hide_long_source_ts.ts.out",
|
||||||
check_stderr: true,
|
check_stderr: true,
|
||||||
exit_code: 1,
|
exit_code: 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
itest!(error_018_hide_long_source_js {
|
itest!(error_018_hide_long_source_js {
|
||||||
args: "error_018_hide_long_source_js.js",
|
args: "run error_018_hide_long_source_js.js",
|
||||||
output: "error_018_hide_long_source_js.js.out",
|
output: "error_018_hide_long_source_js.js.out",
|
||||||
check_stderr: true,
|
check_stderr: true,
|
||||||
exit_code: 1,
|
exit_code: 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
itest!(error_019_stack_function {
|
itest!(error_019_stack_function {
|
||||||
args: "error_019_stack_function.ts",
|
args: "run error_019_stack_function.ts",
|
||||||
output: "error_019_stack_function.ts.out",
|
output: "error_019_stack_function.ts.out",
|
||||||
check_stderr: true,
|
check_stderr: true,
|
||||||
exit_code: 1,
|
exit_code: 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
itest!(error_020_stack_constructor {
|
itest!(error_020_stack_constructor {
|
||||||
args: "error_020_stack_constructor.ts",
|
args: "run error_020_stack_constructor.ts",
|
||||||
output: "error_020_stack_constructor.ts.out",
|
output: "error_020_stack_constructor.ts.out",
|
||||||
check_stderr: true,
|
check_stderr: true,
|
||||||
exit_code: 1,
|
exit_code: 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
itest!(error_021_stack_method {
|
itest!(error_021_stack_method {
|
||||||
args: "error_021_stack_method.ts",
|
args: "run error_021_stack_method.ts",
|
||||||
output: "error_021_stack_method.ts.out",
|
output: "error_021_stack_method.ts.out",
|
||||||
check_stderr: true,
|
check_stderr: true,
|
||||||
exit_code: 1,
|
exit_code: 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
itest!(error_022_stack_custom_error {
|
itest!(error_022_stack_custom_error {
|
||||||
args: "error_022_stack_custom_error.ts",
|
args: "run error_022_stack_custom_error.ts",
|
||||||
output: "error_022_stack_custom_error.ts.out",
|
output: "error_022_stack_custom_error.ts.out",
|
||||||
check_stderr: true,
|
check_stderr: true,
|
||||||
exit_code: 1,
|
exit_code: 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
itest!(error_023_stack_async {
|
itest!(error_023_stack_async {
|
||||||
args: "error_023_stack_async.ts",
|
args: "run error_023_stack_async.ts",
|
||||||
output: "error_023_stack_async.ts.out",
|
output: "error_023_stack_async.ts.out",
|
||||||
check_stderr: true,
|
check_stderr: true,
|
||||||
exit_code: 1,
|
exit_code: 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
itest!(error_024_stack_promise_all {
|
itest!(error_024_stack_promise_all {
|
||||||
args: "error_024_stack_promise_all.ts",
|
args: "run error_024_stack_promise_all.ts",
|
||||||
output: "error_024_stack_promise_all.ts.out",
|
output: "error_024_stack_promise_all.ts.out",
|
||||||
check_stderr: true,
|
check_stderr: true,
|
||||||
exit_code: 1,
|
exit_code: 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
itest!(error_025_tab_indent {
|
itest!(error_025_tab_indent {
|
||||||
args: "error_025_tab_indent",
|
args: "run error_025_tab_indent",
|
||||||
output: "error_025_tab_indent.out",
|
output: "error_025_tab_indent.out",
|
||||||
check_stderr: true,
|
check_stderr: true,
|
||||||
exit_code: 1,
|
exit_code: 1,
|
||||||
|
@ -1534,7 +1534,7 @@ itest!(run_v8_flags {
|
||||||
});
|
});
|
||||||
|
|
||||||
itest!(run_v8_help {
|
itest!(run_v8_help {
|
||||||
args: "--v8-flags=--help",
|
args: "repl --v8-flags=--help",
|
||||||
output: "v8_help.out",
|
output: "v8_help.out",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1544,27 +1544,27 @@ itest!(wasm {
|
||||||
});
|
});
|
||||||
|
|
||||||
itest!(wasm_async {
|
itest!(wasm_async {
|
||||||
args: "wasm_async.js",
|
args: "run wasm_async.js",
|
||||||
output: "wasm_async.out",
|
output: "wasm_async.out",
|
||||||
});
|
});
|
||||||
|
|
||||||
itest!(top_level_await {
|
itest!(top_level_await {
|
||||||
args: "--allow-read top_level_await.js",
|
args: "run --allow-read top_level_await.js",
|
||||||
output: "top_level_await.out",
|
output: "top_level_await.out",
|
||||||
});
|
});
|
||||||
|
|
||||||
itest!(top_level_await_ts {
|
itest!(top_level_await_ts {
|
||||||
args: "--allow-read top_level_await.ts",
|
args: "run --allow-read top_level_await.ts",
|
||||||
output: "top_level_await.out",
|
output: "top_level_await.out",
|
||||||
});
|
});
|
||||||
|
|
||||||
itest!(top_level_for_await {
|
itest!(top_level_for_await {
|
||||||
args: "top_level_for_await.js",
|
args: "run top_level_for_await.js",
|
||||||
output: "top_level_for_await.out",
|
output: "top_level_for_await.out",
|
||||||
});
|
});
|
||||||
|
|
||||||
itest!(top_level_for_await_ts {
|
itest!(top_level_for_await_ts {
|
||||||
args: "top_level_for_await.ts",
|
args: "run top_level_for_await.ts",
|
||||||
output: "top_level_for_await.out",
|
output: "top_level_for_await.out",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,12 @@ console.log(`fetch check code: ${fetchCheckProcCode}`);
|
||||||
const runProc = Deno.run({
|
const runProc = Deno.run({
|
||||||
stdout: "null",
|
stdout: "null",
|
||||||
stderr: "null",
|
stderr: "null",
|
||||||
cmd: [Deno.execPath(), "--lock=lock_write_fetch.json", "https_import.ts"],
|
cmd: [
|
||||||
|
Deno.execPath(),
|
||||||
|
"run",
|
||||||
|
"--lock=lock_write_fetch.json",
|
||||||
|
"https_import.ts",
|
||||||
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
const runCode = (await runProc.status()).code;
|
const runCode = (await runProc.status()).code;
|
||||||
|
|
|
@ -12,6 +12,7 @@ async function startServer(): Promise<Deno.Process> {
|
||||||
// TODO(lucacasonato): remove unstable once possible
|
// TODO(lucacasonato): remove unstable once possible
|
||||||
cmd: [
|
cmd: [
|
||||||
Deno.execPath(),
|
Deno.execPath(),
|
||||||
|
"run",
|
||||||
"--allow-net",
|
"--allow-net",
|
||||||
"--allow-read",
|
"--allow-read",
|
||||||
"--unstable",
|
"--unstable",
|
||||||
|
|
|
@ -6,6 +6,7 @@ Deno.test("[examples/cat] print multiple files", async () => {
|
||||||
const process = Deno.run({
|
const process = Deno.run({
|
||||||
cmd: [
|
cmd: [
|
||||||
Deno.execPath(),
|
Deno.execPath(),
|
||||||
|
"run",
|
||||||
"--allow-read",
|
"--allow-read",
|
||||||
"cat.ts",
|
"cat.ts",
|
||||||
"testdata/cat/hello.txt",
|
"testdata/cat/hello.txt",
|
||||||
|
|
|
@ -77,7 +77,7 @@ Deno.test("[examples/catj] read from stdin", async () => {
|
||||||
|
|
||||||
function catj(...files: string[]): Deno.Process {
|
function catj(...files: string[]): Deno.Process {
|
||||||
return Deno.run({
|
return Deno.run({
|
||||||
cmd: [Deno.execPath(), "--allow-read", "catj.ts", ...files],
|
cmd: [Deno.execPath(), "run", "--allow-read", "catj.ts", ...files],
|
||||||
cwd: "examples",
|
cwd: "examples",
|
||||||
stdin: "piped",
|
stdin: "piped",
|
||||||
stdout: "piped",
|
stdout: "piped",
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { assertStrictEq } from "../../testing/asserts.ts";
|
||||||
Deno.test("[examples/colors] print a colored text", async () => {
|
Deno.test("[examples/colors] print a colored text", async () => {
|
||||||
const decoder = new TextDecoder();
|
const decoder = new TextDecoder();
|
||||||
const process = Deno.run({
|
const process = Deno.run({
|
||||||
cmd: [Deno.execPath(), "colors.ts"],
|
cmd: [Deno.execPath(), "run", "colors.ts"],
|
||||||
cwd: "examples",
|
cwd: "examples",
|
||||||
stdout: "piped",
|
stdout: "piped",
|
||||||
});
|
});
|
||||||
|
|
|
@ -14,7 +14,13 @@ Deno.test({
|
||||||
|
|
||||||
const decoder = new TextDecoder();
|
const decoder = new TextDecoder();
|
||||||
const process = Deno.run({
|
const process = Deno.run({
|
||||||
cmd: [Deno.execPath(), "--allow-net", "curl.ts", "http://localhost:8081"],
|
cmd: [
|
||||||
|
Deno.execPath(),
|
||||||
|
"run",
|
||||||
|
"--allow-net",
|
||||||
|
"curl.ts",
|
||||||
|
"http://localhost:8081",
|
||||||
|
],
|
||||||
cwd: "examples",
|
cwd: "examples",
|
||||||
stdout: "piped",
|
stdout: "piped",
|
||||||
});
|
});
|
||||||
|
|
|
@ -6,7 +6,7 @@ Deno.test("[examples/echo_server]", async () => {
|
||||||
const encoder = new TextEncoder();
|
const encoder = new TextEncoder();
|
||||||
const decoder = new TextDecoder();
|
const decoder = new TextDecoder();
|
||||||
const process = Deno.run({
|
const process = Deno.run({
|
||||||
cmd: [Deno.execPath(), "--allow-net", "echo_server.ts"],
|
cmd: [Deno.execPath(), "run", "--allow-net", "echo_server.ts"],
|
||||||
cwd: "examples",
|
cwd: "examples",
|
||||||
stdout: "piped",
|
stdout: "piped",
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { assertStrictEq } from "../../testing/asserts.ts";
|
||||||
Deno.test("[examples/welcome] print a welcome message", async () => {
|
Deno.test("[examples/welcome] print a welcome message", async () => {
|
||||||
const decoder = new TextDecoder();
|
const decoder = new TextDecoder();
|
||||||
const process = Deno.run({
|
const process = Deno.run({
|
||||||
cmd: [Deno.execPath(), "welcome.ts"],
|
cmd: [Deno.execPath(), "run", "welcome.ts"],
|
||||||
cwd: "examples",
|
cwd: "examples",
|
||||||
stdout: "piped",
|
stdout: "piped",
|
||||||
});
|
});
|
||||||
|
|
|
@ -29,7 +29,7 @@ Deno.test({
|
||||||
name: "xevalCliReplvar",
|
name: "xevalCliReplvar",
|
||||||
fn: async function (): Promise<void> {
|
fn: async function (): Promise<void> {
|
||||||
const p = run({
|
const p = run({
|
||||||
cmd: [execPath(), xevalPath, "--replvar=abc", "console.log(abc)"],
|
cmd: [execPath(), "run", xevalPath, "--replvar=abc", "console.log(abc)"],
|
||||||
stdin: "piped",
|
stdin: "piped",
|
||||||
stdout: "piped",
|
stdout: "piped",
|
||||||
stderr: "null",
|
stderr: "null",
|
||||||
|
@ -45,7 +45,7 @@ Deno.test({
|
||||||
|
|
||||||
Deno.test("xevalCliSyntaxError", async function (): Promise<void> {
|
Deno.test("xevalCliSyntaxError", async function (): Promise<void> {
|
||||||
const p = run({
|
const p = run({
|
||||||
cmd: [execPath(), xevalPath, "("],
|
cmd: [execPath(), "run", xevalPath, "("],
|
||||||
stdin: "null",
|
stdin: "null",
|
||||||
stdout: "piped",
|
stdout: "piped",
|
||||||
stderr: "piped",
|
stderr: "piped",
|
||||||
|
|
|
@ -115,7 +115,7 @@ Deno.test("expandGlobIncludeDirs", async function (): Promise<void> {
|
||||||
Deno.test("expandGlobPermError", async function (): Promise<void> {
|
Deno.test("expandGlobPermError", async function (): Promise<void> {
|
||||||
const exampleUrl = new URL("testdata/expand_wildcard.js", import.meta.url);
|
const exampleUrl = new URL("testdata/expand_wildcard.js", import.meta.url);
|
||||||
const p = run({
|
const p = run({
|
||||||
cmd: [execPath(), "--unstable", exampleUrl.toString()],
|
cmd: [execPath(), "run", "--unstable", exampleUrl.toString()],
|
||||||
stdin: "null",
|
stdin: "null",
|
||||||
stdout: "piped",
|
stdout: "piped",
|
||||||
stderr: "piped",
|
stderr: "piped",
|
||||||
|
|
|
@ -30,6 +30,7 @@ fn basic() {
|
||||||
let build_plugin_output = build_plugin.output().unwrap();
|
let build_plugin_output = build_plugin.output().unwrap();
|
||||||
assert!(build_plugin_output.status.success());
|
assert!(build_plugin_output.status.success());
|
||||||
let output = deno_cmd()
|
let output = deno_cmd()
|
||||||
|
.arg("run")
|
||||||
.arg("--allow-plugin")
|
.arg("--allow-plugin")
|
||||||
.arg("--unstable")
|
.arg("--unstable")
|
||||||
.arg("tests/test.js")
|
.arg("tests/test.js")
|
||||||
|
|
|
@ -20,15 +20,16 @@ import http_server
|
||||||
|
|
||||||
# The list of the tuples of the benchmark name and arguments
|
# The list of the tuples of the benchmark name and arguments
|
||||||
exec_time_benchmarks = [
|
exec_time_benchmarks = [
|
||||||
("hello", ["cli/tests/002_hello.ts"]),
|
("hello", ["run", "cli/tests/002_hello.ts"]),
|
||||||
("relative_import", ["cli/tests/003_relative_import.ts"]),
|
("relative_import", ["run", "cli/tests/003_relative_import.ts"]),
|
||||||
("error_001", ["cli/tests/error_001.ts"]),
|
("error_001", ["run", "cli/tests/error_001.ts"]),
|
||||||
("cold_hello", ["--reload", "cli/tests/002_hello.ts"]),
|
("cold_hello", ["run", "--reload", "cli/tests/002_hello.ts"]),
|
||||||
("cold_relative_import", ["--reload", "cli/tests/003_relative_import.ts"]),
|
("cold_relative_import",
|
||||||
("workers_startup", ["cli/tests/workers_startup_bench.ts"]),
|
["run", "--reload", "cli/tests/003_relative_import.ts"]),
|
||||||
("workers_round_robin", ["cli/tests/workers_round_robin_bench.ts"]),
|
("workers_startup", ["run", "cli/tests/workers_startup_bench.ts"]),
|
||||||
("text_decoder", ["cli/tests/text_decoder_perf.js"]),
|
("workers_round_robin", ["run", "cli/tests/workers_round_robin_bench.ts"]),
|
||||||
("text_encoder", ["cli/tests/text_encoder_perf.js"]),
|
("text_decoder", ["run", "cli/tests/text_decoder_perf.js"]),
|
||||||
|
("text_encoder", ["run", "cli/tests/text_encoder_perf.js"]),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue