Skip to content

Commit

Permalink
fix: improve reading of EPIDATR_USE_CACHE variable
Browse files Browse the repository at this point in the history
  • Loading branch information
dshemetov committed Mar 7, 2024
1 parent c33d7c2 commit 28a49cd
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions R/epidatr-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@
"_PACKAGE"

.onLoad <- function(libname, pkgname) {
cache_environ$use_cache <- Sys.getenv("EPIDATR_USE_CACHE", unset = FALSE)
cache_environ$use_cache <- (cache_environ$use_cache == "TRUE")
cache_environ$use_cache <- as.logical(Sys.getenv("EPIDATR_USE_CACHE", unset = FALSE))
if (is.na(cache_environ$use_cache)) {
cli::cli_warn(
"Failed to read EPIDATR_USE_CACHE environment variable.
Should be a logical. Defaulting to FALSE."
)
cache_environ$use_cache <- FALSE
}
if (cache_environ$use_cache) {
set_cache(startup = TRUE)
}
Expand Down

0 comments on commit 28a49cd

Please sign in to comment.