Skip to content

Commit bd9e3e7

Browse files
committed
Fix empty dir logic
1 parent bae7efc commit bd9e3e7

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

R/use.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ quarto_use_template <- function(
3636
) {
3737
rlang::check_required(template)
3838

39+
if (!fs::dir_exists(dir)) {
40+
fs::dir_create(dir)
41+
}
42+
3943
if (!is_empty_dir(dir) && quarto_available("1.5.15")) {
4044
cli::cli_abort(c(
4145
"{.arg dir} must be an empty directory.",

R/utils.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,10 @@ has_internet <- function(host = "https://www.google.com") {
106106

107107
is_empty_dir <- function(dir) {
108108
if (!dir.exists(dir)) {
109-
return(FALSE)
109+
rlang::warn(
110+
"Directory {.path {dir}} does not exist. Assuming it is empty."
111+
)
112+
return(TRUE)
110113
}
111114
files <- list.files(dir, all.files = TRUE, no.. = TRUE)
112115
length(files) == 0

0 commit comments

Comments
 (0)