R/utils.R

Defines functions check_require

globalVariables(c(".", "admin", "excluded_files", "linter"))

check_require <- function(pkg) {
  full_pkgname <- pkg
  pkgname <- basename(full_pkgname)

  if (!requireNamespace(pkgname, quietly = TRUE)) {
    usethis::ui_stop(
      "Package {usethis::ui_field(pkgname)} needed for this function to work!
       Solution: You can install it with `misc::ipak(\"{ui_field(full_pkgname)}\")`"
    )
  }
}
kguidonimartins/misc documentation built on Dec. 20, 2024, 7:03 p.m.