Skip to content

Commit

Permalink
support recursive directory generation in galah_config()
Browse files Browse the repository at this point in the history
+ test for the same
  • Loading branch information
mjwestgate committed Nov 16, 2023
1 parent 1325ac3 commit 78bc1c0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
5 changes: 2 additions & 3 deletions R/check.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ check_directory <- function(x){
dir.create(cache_dir)
return(cache_dir)
}else{
directory <- dirname(x)
if(!dir.exists(directory)){
dir.create(directory, recursive = TRUE)
if(!dir.exists(x)){
dir.create(x, recursive = TRUE)
}else{
x
}
Expand Down
5 changes: 3 additions & 2 deletions tests/testthat/test-galah_config.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ test_that("galah_config warns that `cache_directory` is deprecated", {
})

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 = "non/existent")
directories <- list.dirs(recursive = TRUE)
expect_true(all(c("./non", "./non/existent") %in% directories))
galah_config(directory = tempfile())
unlink("non", recursive = TRUE)
})
Expand Down

0 comments on commit 78bc1c0

Please sign in to comment.