Skip to content

Commit d742c4e

Browse files
authored
Add more project criteria (#2139)
* Add more project criteria Closes #2133 * Linebreak
1 parent 3938bfb commit d742c4e

File tree

5 files changed

+43
-17
lines changed

5 files changed

+43
-17
lines changed

NEWS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
* `use_package(min_version = FALSE)` is treated the same as when `min_version`
77
is not specified (#2117, @salim-b).
88

9+
* usethis's criteria for recognizing a project have expanded to include (#2133):
10+
- a `.vscode/` directory, which Positron or VS Code might create
11+
- a `_quarto.yml` file, typical of a Quarto project
12+
- an `renv.lock` file, which renv creates
13+
914
# usethis 3.1.0
1015

1116
* `use_vignette()` and `use_article()` support Quarto. The `name` of the new

R/proj.R

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,25 @@ proj_set_ <- function(path) {
1414
#' Most `use_*()` functions act on the **active project**. If it is
1515
#' unset, usethis uses [rprojroot](https://rprojroot.r-lib.org) to
1616
#' find the project root of the current working directory. It establishes the
17-
#' project root by looking for a `.here` file, an RStudio Project, a package
18-
#' `DESCRIPTION`, Git infrastructure, a `remake.yml` file, or a `.projectile`
19-
#' file. It then stores the active project for use for the remainder of the
17+
#' project root by looking for signs such as:
18+
#' * a `.here` file
19+
#' * an RStudio Project, i.e. a `.Rproj` file
20+
#' * an R package, i.e. a `DESCRIPTION` file
21+
#' * a Git repository
22+
#' * a Positron or VS Code workspace, i.e. a `.vscode/` directory
23+
#' * a Quarto project, i.e. a `_quarto.yml` file
24+
#' * an renv project, i.e. a `renv.lock` file
25+
#'
26+
#' usethis then stores the active project for use for the remainder of the
2027
#' session.
2128
#'
2229
#' In general, end user scripts should not contain direct calls to
2330
#' `usethis::proj_*()` utility functions. They are internal functions that are
2431
#' exported for occasional interactive use or use in packages that extend
25-
#' usethis. End user code should call functions in
26-
#' [rprojroot](https://rprojroot.r-lib.org) or its simpler companion,
27-
#' [here](https://here.r-lib.org), to programmatically detect a project and
28-
#' build paths within it.
32+
#' usethis. End user code should call `here::here()` or other functions from
33+
#' the [here](https://here.r-lib.org) or
34+
#' [rprojroot](https://rprojroot.r-lib.org) packages to programmatically
35+
#' detect a project and build paths within it.
2936
#'
3037
#' If you are puzzled why a path (usually the current working directory) does
3138
#' *not* appear to be inside project, it can be helpful to call
@@ -190,6 +197,11 @@ proj_crit <- function() {
190197
rprojroot::is_rstudio_project |
191198
rprojroot::is_r_package |
192199
rprojroot::is_git_root |
200+
# use rprojroot::is_vscode_project at some point in the future
201+
# https://github.com/r-lib/rprojroot/pull/157
202+
rprojroot::has_dir(".vscode") |
203+
rprojroot::is_quarto_project |
204+
rprojroot::is_renv_project |
193205
rprojroot::is_remake_project |
194206
rprojroot::is_projectile_project
195207
}

inst/WORDLIST

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ LinkingTo
4040
METACRAN
4141
Makefile
4242
ORCID
43-
OpenVSX
4443
PATs
4544
PBC
4645
PRs
@@ -133,7 +132,6 @@ labelled
133132
labelling
134133
learnr
135134
libgit
136-
libyajl
137135
lifecycle
138136
ly
139137
macbook
@@ -164,6 +162,7 @@ readme
164162
rebase
165163
reconfigures
166164
redirections
165+
renv
167166
repo
168167
repo's
169168
repos
@@ -207,6 +206,7 @@ useR
207206
usethis's
208207
ver
209208
vm
209+
wc
210210
withr
211211
xyz
212212
xz

man/proj_utils.Rd

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

man/use_air.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)