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

Suppress warning from the project*_path() functions when the file does not already exist #160

Merged
merged 2 commits into from
Aug 14, 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
9 changes: 6 additions & 3 deletions R/processData.R
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,8 @@ project_path <- function(file = NULL) {
if (is.null(file)) {
return(usethis::proj_get())
} else {
return(normalizePath(file.path(usethis::proj_get(), file), winslash = "/"))
return(normalizePath(file.path(usethis::proj_get(), file), winslash = "/",
mustWork = FALSE))
}
}

Expand All @@ -707,7 +708,8 @@ project_extdata_path <- function(file = NULL) {
usethis::proj_get(),
"inst", "extdata", file
),
winslash = "/"
winslash = "/",
mustWork = FALSE
))
}
}
Expand All @@ -734,7 +736,8 @@ project_data_path <- function(file = NULL) {
usethis::proj_get(),
"data", file
),
winslash = "/"
winslash = "/",
mustWork = FALSE
))
}
}
Expand Down
5 changes: 5 additions & 0 deletions tests/testthat/test-project-path.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ datapackage_skeleton(
)
package_build(file.path(tempdir(), "subsetCars"))
usethis::proj_set(file.path(tempdir(), "subsetCars"))
test_that("path functions throw no warning when file does not exist", {
expect_no_warning(project_path('zzzZZZ333.txt'))
expect_no_warning(project_extdata_path('zzzZZZ333.txt'))
expect_no_warning(project_data_path('zzzZZZ333.txt'))
})
test_that("project_path works with file arguments", {
expect_equal(project_path("DESCRIPTION"), expected = file.path(usethis::proj_get(), "DESCRIPTION")) # nolint
})
Expand Down