dotenv
dotenv copied to clipboard
Return the .env output to a list instead of adding to environment
Would you accept a PR for a function with the functionality of dotenv_values?
Might be as simple as
dotenv_values <- function(file = ".env") {
if (!file.exists(file)) stop("dot-env file does not exist", call. = TRUE)
tmp <- readLines(file)
tmp <- ignore_comments(tmp)
tmp <- ignore_empty_lines(tmp)
# If there's no env vars, return nothing
if (length(tmp) == 0) return(list())
tmp <- lapply(tmp, parse_dot_line)
return(tmp)
}
Do you want to submit a PR? Ideally the common parts from the new and the old function would be moved to a new function, and load_dot_env and dotenv_values would both use this new function to avoid code duplication.