Skip to content

Commit

Permalink
When we decline to reprex to avoid overwrite, be chatty about it
Browse files Browse the repository at this point in the history
Closes #435
  • Loading branch information
jennybc committed Jan 11, 2024
1 parent 9fab14a commit 1566d2e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions R/reprex-undo.R
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ reprex_undo <- function(input = NULL,
)
r_file <- r_file_clean(undo_files$filebase)
if (would_clobber(r_file)) {
reprex_warning("Cancelling to avoid overwriting a file.")
return(invisible())
}

Expand Down
1 change: 1 addition & 0 deletions R/reprex_impl.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ reprex_impl <- function(x_expr = NULL,

r_file <- r_file(reprex_files$filebase)
if (would_clobber(r_file)) {
reprex_warning("Cancelling to avoid overwriting a file.")
return(invisible())
}

Expand Down
2 changes: 1 addition & 1 deletion R/utils-io.R
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,10 @@ would_clobber <- function(path) {
if (!file_exists(path)) {
return(FALSE)
}
reprex_path("Oops, file already exists:", path, type = "warning")
if (!is_interactive()) {
return(TRUE)
}
reprex_path("Oops, file already exists:", path, type = "warning")
nope("Carry on and overwrite it?")
}

Expand Down

0 comments on commit 1566d2e

Please sign in to comment.