Skip to content

Commit

Permalink
set .Renviron in working dir
Browse files Browse the repository at this point in the history
  • Loading branch information
sboysel committed Jan 12, 2016
1 parent a3a8959 commit f8b03af
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions R/set_api_key.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ set_api_key <- function(api_key) {
if (!identical(Sys.getenv("FRED_API_KEY"), "")) {
message("FRED API key set as environment variable.")
} else {
renv <- file.path(normalizePath("~"), ".Renviron")
renv <- file.path(getwd(), ".Renviron")
if (file.exists(renv)) {
stop(paste(".Renviron file exists in", normalizePath("~")))
stop(paste(".Renviron file exists in directory"))
}
renv_conn <- file(renv)
writeLines(c(paste0("FRED_API_KEY=", api_key), ""), renv_conn)
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test_set_api_key.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ context("set_api_key is either set of throws an error")
test_that("set_api_key throws an error if .Renviron is present.", {
# Backup
env_key <- Sys.getenv("FRED_API_KEY")
renv <- file.path(normalizePath("~"), ".Renviron")
renv <- file.path(getwd(), ".Renviron")
if (file.exists(renv)) {
file.rename(renv, paste0(renv, ".bak"))
}
Expand Down

0 comments on commit f8b03af

Please sign in to comment.