diff --git a/R/scan-deps.R b/R/scan-deps.R index e841869d..57cb3d8f 100644 --- a/R/scan-deps.R +++ b/R/scan-deps.R @@ -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)) @@ -251,7 +254,8 @@ scan_path_should_cache <- function(paths) { ! basename(paths) %in% c( "_bookdown.yml", "_pkgdown.yml", - "_quarto.yml" + "_quarto.yml", + "renv.lock" ) } @@ -267,6 +271,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") ) } @@ -1005,4 +1010,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_ + ) +} + # ------------------------------------------------------------------------- diff --git a/tests/testthat/_snaps/scan-deps.md b/tests/testthat/_snaps/scan-deps.md index 9a6efac5..c0a6db53 100644 --- a/tests/testthat/_snaps/scan-deps.md +++ b/tests/testthat/_snaps/scan-deps.md @@ -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 1 bookdown/_bookdown.yml bookdown bookdown * prod 1 1 1 2 _pkgdown.yml pkgdown pkgdown * prod 1 1 1 + 3 renv.lock renv renv * prod 1 1 1 diff --git a/tests/testthat/fixtures/scan/project-2/renv.lock b/tests/testthat/fixtures/scan/project-2/renv.lock new file mode 100644 index 00000000..e69de29b diff --git a/tests/testthat/test-scan-deps.R b/tests/testthat/test-scan-deps.R index fdecc2e1..5daaa120 100644 --- a/tests/testthat/test-scan-deps.R +++ b/tests/testthat/test-scan-deps.R @@ -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({