Skip to content

Commit bd8cbf2

Browse files
Merge pull request #86 from gadenbuie/renv-project-criterion
feat: Add `is_renv_project` criterion looking for an `renv.lock` file
2 parents a764d58 + 8c99630 commit bd8cbf2

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export(is_projectile_project)
3030
export(is_quarto_project)
3131
export(is_r_package)
3232
export(is_remake_project)
33+
export(is_renv_project)
3334
export(is_root_criterion)
3435
export(is_rstudio_project)
3536
export(is_svn_root)

R/root.R

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,9 @@ is_drake_project <- has_dir(".drake")
321321
#' @export
322322
is_pkgdown_project <- has_file("_pkgdown.yml") | has_file("_pkgdown.yaml") | has_file("pkgdown/_pkgdown.yml") | has_file("inst/_pkgdown.yml")
323323

324+
#' @export
325+
is_renv_project <- has_file("renv.lock", contents = '"Packages":\\s*\\{')
326+
324327
#' @export
325328
is_projectile_project <- has_file(".projectile")
326329

@@ -355,6 +358,7 @@ criteria <- structure(
355358
is_r_package = is_r_package,
356359
is_remake_project = is_remake_project,
357360
is_pkgdown_project = is_pkgdown_project,
361+
is_renv_project = is_renv_project,
358362
is_projectile_project = is_projectile_project,
359363
is_quarto_project = is_quarto_project,
360364
is_git_root = is_git_root,
@@ -412,6 +416,14 @@ str.root_criteria <- function(object, ...) {
412416
#' @export
413417
"is_pkgdown_project"
414418

419+
#' @details
420+
#' `is_renv_project` looks for an `renv.lock` file.
421+
#'
422+
#' @format NULL
423+
#' @rdname criteria
424+
#' @export
425+
"is_renv_project"
426+
415427
#' @details
416428
#' `is_projectile_project` looks for a `.projectile` file.
417429
#'

man/criteria.Rd

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/_snaps/root.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@
5757
- contains a file "pkgdown/_pkgdown.yml"
5858
- contains a file "inst/_pkgdown.yml"
5959
60+
$is_renv_project
61+
Root criterion: contains a file "renv.lock" with contents matching ""Packages":\s*\{"
62+
6063
$is_projectile_project
6164
Root criterion: contains a file ".projectile"
6265
@@ -91,11 +94,12 @@
9194
Code
9295
str(criteria)
9396
Output
94-
List of 11
97+
List of 12
9598
$ is_rstudio_project : chr "Root criterion: contains a file matching \"[.]Rproj$\" with contents matching \"^Version: \" in the first line"
9699
$ is_r_package : chr "Root criterion: contains a file \"DESCRIPTION\" with contents matching \"^Package: \""
97100
$ is_remake_project : chr "Root criterion: contains a file \"remake.yml\""
98101
$ is_pkgdown_project : chr [1:5] "Root criterion: one of" "- contains a file \"_pkgdown.yml\"" "- contains a file \"_pkgdown.yaml\"" "- contains a file \"pkgdown/_pkgdown.yml\"" ...
102+
$ is_renv_project : chr "Root criterion: contains a file \"renv.lock\" with contents matching \"\"Packages\":\\s*\\{\""
99103
$ is_projectile_project: chr "Root criterion: contains a file \".projectile\""
100104
$ is_quarto_project : chr "Root criterion: contains a file \"_quarto.yml\""
101105
$ is_git_root : chr [1:3] "Root criterion: one of" "- contains a directory \".git\"" "- contains a file \".git\" with contents matching \"^gitdir: \""

0 commit comments

Comments
 (0)