I think it is backwards for the length part, I think that the ! needs to be removed for the length part as currently it is doing the opposite of what you want. It asks when its empty and not when something is already in it in theory but it just seems to always ask when testing it live. Need to dig into why this is occurring.
ask_to_overwrite <- function(directory, ask) {
if (!ask) {
return(TRUE)
}
files <- list.files(directory)
if (!length(files)) {
return(TRUE)
}
usethis::ui_yeah(paste0("The folder is not empty. Files may be overwritten. ",
"Proceed?"))
}
I think it is backwards for the length part, I think that the
!needs to be removed for the length part as currently it is doing the opposite of what you want. It asks when its empty and not when something is already in it in theory but it just seems to always ask when testing it live. Need to dig into why this is occurring.