From 1a3c2e2f1dc5add94b5b7ff4ba4c26df55c7a011 Mon Sep 17 00:00:00 2001 From: Nick Hanley Date: Thu, 16 Mar 2023 12:22:24 -0400 Subject: feat(repl): add `DENO_REPL_HISTORY` to change history file path (#18047) --- cli/cache/deno_dir.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'cli/cache') diff --git a/cli/cache/deno_dir.rs b/cli/cache/deno_dir.rs index 86f3e00b5..2cee0e7a7 100644 --- a/cli/cache/deno_dir.rs +++ b/cli/cache/deno_dir.rs @@ -2,6 +2,7 @@ use super::DiskCache; +use std::env; use std::path::PathBuf; /// `DenoDir` serves as coordinator for multiple `DiskCache`s containing them @@ -109,8 +110,17 @@ impl DenoDir { } /// Path used for the REPL history file. - pub fn repl_history_file_path(&self) -> PathBuf { - self.root.join("deno_history.txt") + /// Can be overridden or disabled by setting `DENO_REPL_HISTORY` environment variable. + pub fn repl_history_file_path(&self) -> Option { + if let Some(deno_repl_history) = env::var_os("DENO_REPL_HISTORY") { + if deno_repl_history.is_empty() { + None + } else { + Some(PathBuf::from(deno_repl_history)) + } + } else { + Some(self.root.join("deno_history.txt")) + } } /// Folder path used for downloading new versions of deno. -- cgit v1.2.3