| 1 |
|
| 2 |
# global variables |
| 3 |
the <- new.env(parent = emptyenv()) |
| 4 |
the$paths <- new.env(parent = emptyenv()) |
| 5 |
|
| 6 |
# detect if we're running on CI |
| 7 |
ci <- function() { |
| 8 |
!is.na(Sys.getenv("CI", unset = NA)) |
| 9 |
} |
| 10 |
|
| 11 |
# check if the renv autoloader is running |
| 12 |
autoloading <- function() { |
| 13 |
getOption("renv.autoloader.running", default = FALSE) |
| 14 |
} |
| 15 |
|
| 16 |
# detect if we're running within R CMD build |
| 17 |
building <- function() { |
| 18 |
nzchar(Sys.getenv("R_CMD")) && |
| 19 |
grepl("Rbuild", basename(dirname(getwd())), fixed = TRUE) |
| 20 |
} |
| 21 |
|
| 22 |
# detect if we're running within R CMD INSTALL |
| 23 |
installing <- function() { |
| 24 |
nzchar(Sys.getenv("R_INSTALL_PKG")) |
| 25 |
} |
| 26 |
|
| 27 |
# are we running code within R CMD check? |
| 28 |
checking <- function() { |
| 29 |
"CheckExEnv" %in% search() || |
| 30 |
renv_envvar_exists("_R_CHECK_PACKAGE_NAME_") || |
| 31 |
renv_envvar_exists("_R_CHECK_SIZE_OF_TARBALL_") |
| 32 |
} |
| 33 |
|
| 34 |
# NOTE: Prefer using 'testing()' to 'renv_tests_running()' for behavior |
| 35 |
# that should apply regardless of the package currently being tested. |
| 36 |
# |
| 37 |
# 'renv_tests_running()' is appropriate when running renv's own tests. |
| 38 |
testing <- function() { |
| 39 |
identical(Sys.getenv("TESTTHAT"), "true") |
| 40 |
} |
| 41 |
|
| 42 |
devel <- function() { |
| 43 |
identical(R.version[["status"]], "Under development (unstable)") |
| 44 |
} |
| 45 |
|
| 46 |
devmode <- function() { |
| 47 |
|
| 48 |
if ("devtools" %in% loadedNamespaces()) { |
| 49 |
if (.packageName %in% devtools::dev_packages()) { |
| 50 |
return(TRUE) |
| 51 |
} |
| 52 |
} |
| 53 |
|
| 54 |
if (Sys.getenv("DEVTOOLS_LOAD") == .packageName) |
| 55 |
return(TRUE) |
| 56 |
|
| 57 |
FALSE |
| 58 |
|
| 59 |
} |