Skip to content

Commit 10ec8de

Browse files
authored
Add a clickable link to file when already exists and not generated by roxygen2 (#1556)
1 parent fb87b7f commit 10ec8de

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

R/utils.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ write_if_different <- function(path, contents, command = NULL, check = TRUE) {
6969
name <- basename(path)
7070
if (check && !made_by_roxygen(path)) {
7171
cli::cli_inform(c(
72-
x = "Skipping {.path {name}}",
72+
x = "Skipping {.href [{name}](file://{path})}",
7373
i = "It already exists and was not generated by {.pkg roxygen2}."
7474
))
7575
return(FALSE)

tests/testthat/_snaps/utils.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
Code
1313
write_if_different(path, "a <- 2")
1414
Message
15-
x Skipping 'test.R'
15+
x Skipping test.R (<file:///test.R>)
1616
i It already exists and was not generated by roxygen2.
1717
Output
1818
[1] FALSE

tests/testthat/test-utils.R

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ test_that("write_if_different produces informative messages", {
2222
expect_snapshot(write_if_different(path, "a <- 2"))
2323

2424
write_lines("a <- 1", path)
25-
expect_snapshot(write_if_different(path, "a <- 2"))
25+
# strip temp path
26+
expect_snapshot(
27+
write_if_different(path, "a <- 2"),
28+
transform = function(x) gsub(dir, "", x, fixed = TRUE)
29+
)
2630

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

0 commit comments

Comments
 (0)