Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return the .env output to a list instead of adding to environment #12

Open
dshemetov opened this issue Mar 28, 2023 · 1 comment · May be fixed by #13
Open

Return the .env output to a list instead of adding to environment #12

dshemetov opened this issue Mar 28, 2023 · 1 comment · May be fixed by #13

Comments

@dshemetov
Copy link

dshemetov commented Mar 28, 2023

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)
}
@gaborcsardi
Copy link
Owner

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.

@dshemetov dshemetov linked a pull request Apr 14, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants