Skip to content

Commit

Permalink
Add a clickable link to file when already exists and not generated by…
Browse files Browse the repository at this point in the history
… roxygen2 (#1556)
  • Loading branch information
olivroy authored Jul 10, 2024
1 parent fb87b7f commit 10ec8de
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ write_if_different <- function(path, contents, command = NULL, check = TRUE) {
name <- basename(path)
if (check && !made_by_roxygen(path)) {
cli::cli_inform(c(
x = "Skipping {.path {name}}",
x = "Skipping {.href [{name}](file://{path})}",
i = "It already exists and was not generated by {.pkg roxygen2}."
))
return(FALSE)
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/_snaps/utils.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
Code
write_if_different(path, "a <- 2")
Message
x Skipping 'test.R'
x Skipping test.R (<file:///test.R>)
i It already exists and was not generated by roxygen2.
Output
[1] FALSE
Expand Down
6 changes: 5 additions & 1 deletion tests/testthat/test-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ test_that("write_if_different produces informative messages", {
expect_snapshot(write_if_different(path, "a <- 2"))

write_lines("a <- 1", path)
expect_snapshot(write_if_different(path, "a <- 2"))
# strip temp path
expect_snapshot(
write_if_different(path, "a <- 2"),
transform = function(x) gsub(dir, "", x, fixed = TRUE)
)

path <- file.path(dir, "+.R")
expect_snapshot(write_if_different(path, "a <- 2"))
Expand Down

0 comments on commit 10ec8de

Please sign in to comment.