rprojroot/ 0000755 0001762 0000144 00000000000 14521666122 012317 5 ustar ligges users rprojroot/NAMESPACE 0000644 0001762 0000144 00000002173 14521632656 013546 0 ustar ligges users # Generated by roxygen2: do not edit by hand S3method("|",root_criterion) S3method(as_root_criterion,character) S3method(as_root_criterion,default) S3method(as_root_criterion,root_criterion) S3method(format,root_criterion) S3method(print,root_criterion) S3method(str,root_criteria) export(as.root_criterion) export(as_root_criterion) export(criteria) export(find_package_root_file) export(find_remake_root_file) export(find_root) export(find_root_file) export(find_rstudio_root_file) export(find_testthat_root_file) export(from_wd) export(get_root_desc) export(has_basename) export(has_dir) export(has_file) export(has_file_pattern) export(is.root_criterion) export(is_drake_project) export(is_git_root) export(is_pkgdown_project) export(is_projectile_project) export(is_quarto_project) export(is_r_package) export(is_remake_project) export(is_renv_project) export(is_root_criterion) export(is_rstudio_project) export(is_svn_root) export(is_testthat) export(is_vcs_root) export(root_criterion) export(thisfile) export(thisfile_knit) export(thisfile_r) export(thisfile_rscript) export(thisfile_source) importFrom(utils,str) importFrom(utils,tail) rprojroot/LICENSE 0000644 0001762 0000144 00000000057 14136674000 013322 0 ustar ligges users YEAR: 2020 COPYRIGHT HOLDER: rprojroot authors rprojroot/README.md 0000644 0001762 0000144 00000020032 14473542244 013577 0 ustar ligges users # [rprojroot](https://rprojroot.r-lib.org/) [](https://lifecycle.r-lib.org/articles/stages.html) [](https://github.com/r-lib/rprojroot/actions) [](https://cran.r-project.org/package=rprojroot) [](https://app.codecov.io/gh/r-lib/rprojroot?branch=main) This package helps accessing files relative to a *project root* to [stop the working directory insanity](https://gist.github.com/jennybc/362f52446fe1ebc4c49f). It is a low-level helper package for the [here](https://here.r-lib.org/) package.
library(rprojroot)## Example The rprojroot package works best when you have a “project”: all related files contained in a subdirectory that can be categorized using a strict criterion. Let’s create a package for demonstration.
dir <- tempfile() pkg <- usethis::create_package(dir) #> ✓ Creating '/tmp/RtmpBLE08t/file294c3c8acca7/' #> ✓ Setting active project to '/tmp/RtmpBLE08t/file294c3c8acca7' #> ✓ Creating 'R/' #> ✓ Writing 'DESCRIPTION' #> Package: file294c3c8acca7 #> Title: What the Package Does (One Line, Title Case) #> Version: 0.0.0.9000 #> Date: 2020-11-08 #> Authors@R (parsed): #> * Kirill Müller <krlmlr+r@mailbox.org> [aut, cre] (<https://orcid.org/0000-0002-1416-3412>) #> Description: What the package does (one paragraph). #> License: GPL-3 #> URL: https://github.com/krlmlr/rprojroot, #> https://krlmlr.github.io/rprojroot #> BugReports: https://github.com/krlmlr/rprojroot/issues #> Encoding: UTF-8 #> LazyData: true #> Roxygen: list(markdown = TRUE) #> RoxygenNote: 7.1.1.9000 #> ✓ Writing 'NAMESPACE' #> ✓ Setting active project to '<no active project>'R packages satisfy the `is_r_package` criterion. A criterion is an object that contains a `find_file()` function. With `pkg` as working directory, the function works like [`file.path()`](https://rdrr.io/r/base/file.path.html), rooted at the working directory:
setwd(pkg) is_r_package #> Root criterion: contains a file `DESCRIPTION` with contents matching `^Package: ` is_r_package$find_file() #> [1] "/tmp/RtmpBLE08t/file294c3c8acca7" is_r_package$find_file("tests", "testthat") #> [1] "/tmp/RtmpBLE08t/file294c3c8acca7/tests/testthat"This works identically when starting from a subdirectory:
setwd(file.path(pkg, "R")) is_r_package$find_file() #> [1] "/tmp/RtmpBLE08t/file294c3c8acca7" is_r_package$find_file("tests", "testthat") #> [1] "/tmp/RtmpBLE08t/file294c3c8acca7/tests/testthat"There is one exception: if the first component passed to `find_file()` is already an absolute path. This allows safely applying this function to paths that may be absolute or relative:
setwd(file.path(pkg, "R")) path <- is_r_package$find_file() is_r_package$find_file(path, "tests", "testthat") #> [1] "/tmp/RtmpBLE08t/file294c3c8acca7/tests/testthat"As long as you are sure that your working directory is somewhere inside your project, you can retrieve the project root. ## Installation and further reading Install the package from CRAN:
install.package("rprojroot")See the [documentation](https://rprojroot.r-lib.org/articles/rprojroot.html) for more detail. ------------------------------------------------------------------------ ## Code of Conduct Please note that the rprojroot project is released with a [Contributor Code of Conduct](https://rprojroot.r-lib.org/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms. rprojroot/man/ 0000755 0001762 0000144 00000000000 14521632656 013077 5 ustar ligges users rprojroot/man/criteria.Rd 0000644 0001762 0000144 00000003361 14521632656 015173 0 ustar ligges users % Generated by roxygen2: do not edit by hand % Please edit documentation in R/root.R \docType{data} \name{criteria} \alias{criteria} \alias{is_rstudio_project} \alias{is_r_package} \alias{is_remake_project} \alias{is_drake_project} \alias{is_pkgdown_project} \alias{is_renv_project} \alias{is_projectile_project} \alias{is_quarto_project} \alias{is_git_root} \alias{is_svn_root} \alias{is_vcs_root} \alias{is_testthat} \alias{from_wd} \title{Prespecified criteria} \usage{ criteria is_rstudio_project is_r_package is_remake_project is_drake_project is_pkgdown_project is_renv_project is_projectile_project is_quarto_project is_git_root is_svn_root is_vcs_root is_testthat from_wd } \description{ This is a collection of commonly used root criteria. } \details{ \code{is_rstudio_project} looks for a file with extension \code{.Rproj}. \code{is_r_package} looks for a \code{DESCRIPTION} file. \code{is_remake_project} looks for a \code{remake.yml} file. \code{is_drake_project} looks for a \code{.drake} directory. \code{is_pkgdown_project} looks for a \verb{_pkgdown.yml}, \verb{_pkgdown.yaml}, \verb{pkgdown/_pkgdown.yml} and/or \verb{inst/_pkgdown.yml} file. \code{is_renv_project} looks for an \code{renv.lock} file. \code{is_projectile_project} looks for a \code{.projectile} file. \code{is_quarto_project} looks for a \verb{_quarto.yml} file. \code{is_git_root} looks for a \code{.git} directory. \code{is_svn_root} looks for a \code{.svn} directory. \code{is_vcs_root} looks for the root of a version control system, currently only Git and SVN are supported. \code{is_testthat} looks for the \code{testthat} directory, works when developing, testing, and checking a package. \code{from_wd} uses the current working directory. } \keyword{datasets} rprojroot/man/rprojroot-package.Rd 0000644 0001762 0000144 00000002122 14473542516 017015 0 ustar ligges users % Generated by roxygen2: do not edit by hand % Please edit documentation in R/rprojroot-package.R \docType{package} \name{rprojroot-package} \alias{rprojroot} \alias{rprojroot-package} \title{rprojroot: Finding Files in Project Subdirectories} \description{ Robust, reliable and flexible paths to files below a project root. The 'root' of a project is defined as a directory that matches a certain criterion, e.g., it contains a certain regular file. } \details{ See the "Value" section in \code{\link[=root_criterion]{root_criterion()}} for documentation of root criterion objects, and \link{criteria} for useful predefined root criteria. } \examples{ criteria \dontrun{ is_r_package$find_file("NAMESPACE") root_fun <- is_r_package$make_fix_file() root_fun("NAMESPACE") } } \seealso{ Useful links: \itemize{ \item \url{https://rprojroot.r-lib.org/} \item \url{https://github.com/r-lib/rprojroot} \item Report bugs at \url{https://github.com/r-lib/rprojroot/issues} } } \author{ \strong{Maintainer}: Kirill Müller \email{kirill@cynkra.com} (\href{https://orcid.org/0000-0002-1416-3412}{ORCID}) } rprojroot/man/find_root_file.Rd 0000644 0001762 0000144 00000004031 14136674000 016335 0 ustar ligges users % Generated by roxygen2: do not edit by hand % Please edit documentation in R/file.R, R/shortcut.R \name{find_root_file} \alias{find_root_file} \alias{find_rstudio_root_file} \alias{find_package_root_file} \alias{find_remake_root_file} \alias{find_testthat_root_file} \title{File paths relative to the root of a directory hierarchy} \usage{ find_root_file(..., criterion, path = ".") find_rstudio_root_file(..., path = ".") find_package_root_file(..., path = ".") find_remake_root_file(..., path = ".") find_testthat_root_file(..., path = ".") } \arguments{ \item{...}{\verb{[character]}\cr Further path components passed to \code{\link[=file.path]{file.path()}}. All arguments must be the same length or length one.} \item{criterion}{\verb{[root_criterion]}\cr A criterion, one of the predefined \link{criteria} or created by \code{\link[=root_criterion]{root_criterion()}}. Will be coerced using \code{\link[=as_root_criterion]{as_root_criterion()}}.} \item{path}{\verb{[character(1)]}\cr The start directory.} } \value{ The normalized path of the root as specified by the search criteria, with the additional path components appended. Throws an error if no root is found. } \description{ \code{find_root_file()} is a wrapper around \code{\link[=find_root]{find_root()}} that appends an arbitrary number of path components to the root using \code{\link[base:file.path]{base::file.path()}}. } \details{ This function operates on the notion of relative paths. The \code{...} argument is expected to contain a path relative to the root. If the first path component passed to \code{...} is already an absolute path, the \code{criterion} and \code{path} arguments are ignored, and \code{...} is forwarded to \code{\link[=file.path]{file.path()}}. } \examples{ \dontrun{ find_package_root_file("tests", "testthat.R") has_file("DESCRIPTION", "^Package: ")$find_file has_file("DESCRIPTION", "^Package: ")$make_fix_file(".") } } \seealso{ \code{\link[=find_root]{find_root()}} \code{\link[utils:glob2rx]{utils::glob2rx()}} \code{\link[base:file.path]{base::file.path()}} } rprojroot/man/figures/ 0000755 0001762 0000144 00000000000 14136674000 014532 5 ustar ligges users rprojroot/man/figures/lifecycle-defunct.svg 0000644 0001762 0000144 00000001704 14136674000 020642 0 ustar ligges users