diff --git a/R/check.R b/R/check.R index c4c8e0db..dc0a2caa 100644 --- a/R/check.R +++ b/R/check.R @@ -38,7 +38,7 @@ check_directory <- function(x){ }else{ directory <- dirname(x) if(!dir.exists(directory)){ - dir.create(directory) + dir.create(directory, recursive = TRUE) }else{ x } diff --git a/R/deprecated_functions.R b/R/deprecated_functions.R index c30b6363..b75d99b8 100644 --- a/R/deprecated_functions.R +++ b/R/deprecated_functions.R @@ -15,11 +15,11 @@ #' atlas_taxonomy() #' } #' @rdname deprecated-functions -#' @importFrom rlang warn +#' @importFrom lifecycle deprecate_warn #' @export galah_down_to <- function(...){ - lifecycle::deprecate_warn(when = "2.0.0", + deprecate_warn(when = "2.0.0", what = "galah_down_to()", details = "Use `filter(rank == \"chosen_rank\")` instead." ) diff --git a/R/galah_config.R b/R/galah_config.R index 72558e05..ffe1442e 100644 --- a/R/galah_config.R +++ b/R/galah_config.R @@ -63,6 +63,8 @@ #' # Make debugging in your session easier by setting `verbose = TRUE` #' galah_config(verbose = TRUE) #' } +#' @importFrom lifecycle deprecate_warn +#' @importFrom glue glue #' @importFrom rlang abort #' @importFrom potions brew #' @importFrom potions pour @@ -80,6 +82,18 @@ galah_config <- function(...) { # add user-provided information if(length(dots) > 0){ + + # check for deprecated `cache_directory` + if(any(names(dots) == "cache_directory")){ + dots_location <- which(names(dots) == "cache_directory") + value <- dots$cache_directory + deprecate_warn(when = "2.0.0", + what = "galah_config(cache_directory)", + details = glue("Use `galah_config(directory = \"{value}\")` instead.") + ) + names(dots)[dots_location] <- "directory" + } + # check all values in dots to ensure they are named if(length(dots) != length(names(dots))){ bullets <- c("All arguments to `galah_config() must be named.", diff --git a/tests/testthat/test-galah_config.R b/tests/testthat/test-galah_config.R index b3648dd0..81712868 100644 --- a/tests/testthat/test-galah_config.R +++ b/tests/testthat/test-galah_config.R @@ -1,3 +1,18 @@ +test_that("galah_config warns that `cache_directory` is deprecated", { + dir.create("temp") + expect_warning(galah_config(cache_directory = "temp")) + expect_true(galah_config()$package$directory == "temp") + galah_config(directory = tempfile()) + unlink("temp", recursive = TRUE) +}) + +test_that("galah_config creates nested folders where requested", { + galah_config(directory = "non/existent/dir") + expect_true(any(grepl("./non", list.dirs()))) + galah_config(directory = tempfile()) + unlink("non", recursive = TRUE) +}) + test_that("galah_config checks download_id", { skip_if_offline() galah_config(verbose = TRUE) @@ -14,7 +29,6 @@ test_that("galah_config checks inputs", { expect_error(galah_config(caching = "value")) expect_error(galah_config(verbose = "value")) expect_error(galah_config(email = 4)) - expect_error(galah_config(cache_directory = "non/existent/dir")) expect_error(galah_config(bad_option = "value")) expect_error(galah_config(atlas = "world")) expect_silent(galah_config(verbose = FALSE, atlas = "Australia"))