R/zzz.R

Defines functions is_loading_for_tests is_attached .onAttach

.onAttach <- function(...) {
  msg <- paste(
    "Do not use `library(config)` to attach the config package.",
    "Use `config::get()` directly.",
    "Attaching the config package can lead to namespace conflicts.",
    sep = "\n"
  )
  if (!is_loading_for_tests()) {
    packageStartupMessage(msg, appendLF = TRUE)
  }
}

is_attached <- function(x) {
  paste0("package:", x) %in% search()
}

is_loading_for_tests <- function() {
  identical(Sys.getenv("DEVTOOLS_LOAD"), "config")
}

Try the config package in your browser

Any scripts or data that you put into this service are public.

config documentation built on Aug. 30, 2023, 5:16 p.m.