Skip to content

ask_to_overwrite() check if this function is working as expected #15

Description

@aylapear

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?"))
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions