Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a clickable link to file when already exists and not generated by roxygen2 #1556

Merged
merged 6 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading