Skip to content

Commit

Permalink
scan_deps() renv.lock means we need renv (#412)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaborcsardi authored Dec 15, 2024
1 parent 040acf5 commit 0978545
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
15 changes: 14 additions & 1 deletion R/scan-deps.R
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ scan_deps <- function(path = ".") {
if (file.exists(file.path(path, "_pkgdown.yml"))) {
paths <- c(paths, "_pkgdown.yml")
}
if (file.exists(file.path(path, "renv.lock"))) {
paths <- c(paths, "renv.lock")
}
full_paths <- normalizePath(file.path(path, paths))
deps_list <- lapply(full_paths, scan_path_deps)
deps <- do.call("rbind", c(list(scan_deps_df()), deps_list))
Expand Down Expand Up @@ -253,7 +256,8 @@ scan_path_should_cache <- function(paths) {
! basename(paths) %in% c(
"_bookdown.yml",
"_pkgdown.yml",
"_quarto.yml"
"_quarto.yml",
"renv.lock"
)
}

Expand All @@ -270,6 +274,7 @@ scan_path_deps_do <- function(code, path) {
"_bookdown.yml" = scan_path_deps_do_bookdown(code, path),
"_pkgdown.yml" = scan_path_deps_do_pkgdown(code, path),
"_quarto.yml" = scan_path_deps_do_quarto(code, path),
"renv.lock" = scan_path_deps_do_renv_lock(code, path),
stop("Cannot parse ", ext, " file for dependencies, internal error")
)
}
Expand Down Expand Up @@ -1008,4 +1013,12 @@ scan_path_deps_do_quarto <- function(code, path) {
# Maybe that's too opinionated?
}

scan_path_deps_do_renv_lock <- function(code, path) {
scan_deps_df(
path = path,
package = "renv",
code = NA_character_
)
}

# -------------------------------------------------------------------------
5 changes: 3 additions & 2 deletions tests/testthat/_snaps/scan-deps.md
Original file line number Diff line number Diff line change
Expand Up @@ -381,14 +381,15 @@
1 fixtures/scan/NAMESPACE stats stats * prod stats 1 1 1
2 fixtures/scan/NAMESPACE utils utils * prod utils 1 1 1

# scan_path_deps_do_{bookdown,pkgdown,quarto}
# scan_path_deps_do_{bookdown,pkgdown,quarto,renv_lock}

Code
scan_deps(project)[]
Output
# A data frame: 2 x 9
# A data frame: 3 x 9
path ref package version type code start_row start_column start_byte
<chr> <chr> <chr> <chr> <chr> <chr> <int> <int> <int>
1 bookdown/_bookdown.yml bookdown bookdown * prod <NA> 1 1 1
2 _pkgdown.yml pkgdown pkgdown * prod <NA> 1 1 1
3 renv.lock renv renv * prod <NA> 1 1 1

Empty file.
2 changes: 1 addition & 1 deletion tests/testthat/test-scan-deps.R
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ test_that("scan_path_deps_do_namespace", {
})
})

test_that("scan_path_deps_do_{bookdown,pkgdown,quarto}", {
test_that("scan_path_deps_do_{bookdown,pkgdown,quarto,renv_lock}", {
local_reproducible_output(width = 500)
project <- test_path("fixtures/scan/project-2")
expect_snapshot({
Expand Down

0 comments on commit 0978545

Please sign in to comment.