From f5c23f8058ed7ce85846c6b1e623329a09fa1a76 Mon Sep 17 00:00:00 2001 From: Casper Beyer Date: Mon, 19 Oct 2020 19:41:25 +0800 Subject: fix(cli/repl): write all results to stdout (#7893) This writes all evaluaton results to stdout regardless if the result is an error or not. This matches the behavior of other read-eval-print-loops like Node. --- cli/repl.rs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'cli/repl.rs') diff --git a/cli/repl.rs b/cli/repl.rs index 2e41b0565..be887e941 100644 --- a/cli/repl.rs +++ b/cli/repl.rs @@ -391,16 +391,13 @@ pub async fn run( let inspect_result = inspect_response.get("result").unwrap(); - match evaluate_exception_details { - Some(_) => eprintln!( - "Uncaught {}", - inspect_result.get("value").unwrap().as_str().unwrap() - ), - None => println!( - "{}", - inspect_result.get("value").unwrap().as_str().unwrap() - ), - } + let value = inspect_result.get("value").unwrap().as_str().unwrap(); + let output = match evaluate_exception_details { + Some(_) => format!("Uncaught {}", value), + None => value.to_string(), + }; + + println!("{}", output); editor.lock().unwrap().add_history_entry(line.as_str()); } -- cgit v1.2.3