summaryrefslogtreecommitdiff
path: root/cli/cache/deno_dir.rs
diff options
context:
space:
mode:
authorNick Hanley <nicholasjhanley@gmail.com>2023-03-16 12:22:24 -0400
committerGitHub <noreply@github.com>2023-03-17 01:22:24 +0900
commit1a3c2e2f1dc5add94b5b7ff4ba4c26df55c7a011 (patch)
treef300370c4d96ccfce91d850f2451339e3c464152 /cli/cache/deno_dir.rs
parentb25876355888158167ebdefe50c0a88a2d33a38f (diff)
feat(repl): add `DENO_REPL_HISTORY` to change history file path (#18047)
Diffstat (limited to 'cli/cache/deno_dir.rs')
-rw-r--r--cli/cache/deno_dir.rs14
1 files changed, 12 insertions, 2 deletions
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<PathBuf> {
+ 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.