From 04ed8d0531b7c2c308b28b742f5c332345d97065 Mon Sep 17 00:00:00 2001 From: Nayeem Rahman Date: Fri, 11 Oct 2019 18:12:39 +0100 Subject: Ensure DENO_DIR when saving the REPL history (#3106) --- cli/repl.rs | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) (limited to 'cli') diff --git a/cli/repl.rs b/cli/repl.rs index 0cac6c4ea..7abb76708 100644 --- a/cli/repl.rs +++ b/cli/repl.rs @@ -2,6 +2,7 @@ use crate::deno_dir::DenoDir; use deno::ErrBox; use rustyline; +use std::fs; use std::path::PathBuf; #[cfg(not(windows))] @@ -76,14 +77,7 @@ impl Repl { } fn save_history(&mut self) -> Result<(), ErrBox> { - if !self.history_dir_exists() { - eprintln!( - "Unable to save REPL history: {:?} directory does not exist", - self.history_file - ); - return Ok(()); - } - + fs::create_dir_all(self.history_file.parent().unwrap())?; self .editor .save_history(&self.history_file.to_str().unwrap()) @@ -94,14 +88,6 @@ impl Repl { }) } - fn history_dir_exists(&self) -> bool { - self - .history_file - .parent() - .map(|ref p| p.exists()) - .unwrap_or(false) - } - pub fn readline(&mut self, prompt: &str) -> Result { self .editor -- cgit v1.2.3