diff options
author | Nayeem Rahman <muhammed.9939@gmail.com> | 2019-10-11 18:12:39 +0100 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2019-10-11 10:12:39 -0700 |
commit | 04ed8d0531b7c2c308b28b742f5c332345d97065 (patch) | |
tree | 2e59a321919c8ce3161dd6208420f139185bf359 /cli/repl.rs | |
parent | ab63e598176a778691b3db64b559934b885ec3bf (diff) |
Ensure DENO_DIR when saving the REPL history (#3106)
Diffstat (limited to 'cli/repl.rs')
-rw-r--r-- | cli/repl.rs | 18 |
1 files changed, 2 insertions, 16 deletions
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<String, ErrBox> { self .editor |