summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/args/mod.rs7
-rw-r--r--cli/tests/repl_tests.rs19
-rw-r--r--cli/tools/repl/mod.rs17
3 files changed, 36 insertions, 7 deletions
diff --git a/cli/args/mod.rs b/cli/args/mod.rs
index d1ff39f98..38e0abea0 100644
--- a/cli/args/mod.rs
+++ b/cli/args/mod.rs
@@ -460,6 +460,13 @@ impl CliOptions {
self.flags.log_level
}
+ pub fn is_quiet(&self) -> bool {
+ self
+ .log_level()
+ .map(|l| l == log::Level::Error)
+ .unwrap_or(false)
+ }
+
pub fn location_flag(&self) -> Option<&Url> {
self.flags.location.as_ref()
}
diff --git a/cli/tests/repl_tests.rs b/cli/tests/repl_tests.rs
index edc7918f9..281ae0746 100644
--- a/cli/tests/repl_tests.rs
+++ b/cli/tests/repl_tests.rs
@@ -732,7 +732,7 @@ mod repl {
);
assert_contains!(
test_util::strip_ansi_codes(&out),
- "error in --eval flag. parse error: Unexpected token `%`."
+ "Error in --eval flag: parse error: Unexpected token `%`."
);
assert_contains!(out, "2500"); // should not prevent input
assert!(err.is_empty());
@@ -747,7 +747,7 @@ mod repl {
None,
false,
);
- assert_contains!(out, "error in --eval flag. Uncaught Error: Testing");
+ assert_contains!(out, "Error in --eval flag: Uncaught Error: Testing");
assert_contains!(out, "2500"); // should not prevent input
assert!(err.is_empty());
}
@@ -881,4 +881,19 @@ mod repl {
assert_contains!(out, "AggregateError");
assert!(err.is_empty());
}
+
+ #[test]
+ fn repl_with_quiet_flag() {
+ let (out, err) = util::run_and_collect_output_with_args(
+ true,
+ vec!["repl", "--quiet"],
+ Some(vec!["await Promise.resolve('done')"]),
+ Some(vec![("NO_COLOR".to_owned(), "1".to_owned())]),
+ false,
+ );
+ assert!(!out.contains("Deno"));
+ assert!(!out.contains("exit using ctrl+d, ctrl+c, or close()"));
+ assert_ends_with!(out, "\"done\"\n");
+ assert!(err.is_empty());
+ }
}
diff --git a/cli/tools/repl/mod.rs b/cli/tools/repl/mod.rs
index 1cdb17ab1..afbd39eff 100644
--- a/cli/tools/repl/mod.rs
+++ b/cli/tools/repl/mod.rs
@@ -101,11 +101,14 @@ pub async fn run(
.await?;
// only output errors
if let EvaluationOutput::Error(error_text) = output {
- println!("error in --eval-file file {}. {}", eval_file, error_text);
+ println!(
+ "Error in --eval-file file \"{}\": {}",
+ eval_file, error_text
+ );
}
}
Err(e) => {
- println!("error in --eval-file file {}. {}", eval_file, e);
+ println!("Error in --eval-file file \"{}\": {}", eval_file, e);
}
}
}
@@ -115,12 +118,16 @@ pub async fn run(
let output = repl_session.evaluate_line_and_get_output(&eval).await?;
// only output errors
if let EvaluationOutput::Error(error_text) = output {
- println!("error in --eval flag. {}", error_text);
+ println!("Error in --eval flag: {}", error_text);
}
}
- println!("Deno {}", crate::version::deno());
- println!("exit using ctrl+d, ctrl+c, or close()");
+ // Doing this manually, instead of using `log::info!` because these messages
+ // are supposed to go to stdout, not stderr.
+ if !ps.options.is_quiet() {
+ println!("Deno {}", crate::version::deno());
+ println!("exit using ctrl+d, ctrl+c, or close()");
+ }
loop {
let line = read_line_and_poll(