Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding utils::for packageName #5

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions R/standalone-check_pkg_installed.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@
#' location of `R` library trees to search through, see [utils::packageDescription()].
#'
#' @details
#' The `ref` argument (`pkg` in `get_pkg_dependencies`) uses `packageName()` as a default, which returns the package in
#' The `ref` argument (`pkg` in `get_pkg_dependencies`) uses `utils::packageName()` as a default, which returns the package in
#' which the current environment or function is run from. The current environment is determined via `parent.frame()`.
#'
#' If, for example, `get_min_version_required("dplyr", ref = packageName())` is run within a `cards` function, and this
#' If, for example, `get_min_version_required("dplyr", ref = utils::packageName())` is run within a `cards` function, and this
#' function is then called within a function of the `cardx` package, the minimum version returned by the
#' `get_min_version_required` call will return the version required by the `cards` package. If run within a test file,
#' `packageName()` returns the package of the current test. Within Roxygen `@examplesIf` calls, `packageName()` will
#' `utils::packageName()` returns the package of the current test. Within Roxygen `@examplesIf` calls, `utils::packageName()` will
#' returns the package of the current example.
#'
#' @return `is_pkg_installed()` and `check_pkg_installed()` returns a logical or error,
Expand All @@ -70,7 +70,7 @@ NULL
#' @keywords internal
#' @noRd
check_pkg_installed <- function(pkg,
ref = packageName(),
ref = utils::packageName(),
call = get_cli_abort_call()) {
if (!is.character(ref) && !is.null(ref)) cli::cli_abort("{.arg ref} must be a string.")

Expand All @@ -93,7 +93,7 @@ check_pkg_installed <- function(pkg,
#' @keywords internal
#' @noRd
is_pkg_installed <- function(pkg,
ref = packageName()) {
ref = utils::packageName()) {
if (!is.character(ref) && !is.null(ref)) cli::cli_abort("{.arg ref} must be a string.")

# get min version data -------------------------------------------------------
Expand All @@ -117,7 +117,7 @@ is_pkg_installed <- function(pkg,
#' name of the package the function will search for dependencies from.
#'
#' @noRd
get_pkg_dependencies <- function(pkg = packageName(), lib.loc = NULL) {
get_pkg_dependencies <- function(pkg = utils::packageName(), lib.loc = NULL) {
if (!is.character(pkg) && !is.null(pkg)) cli::cli_abort("{.arg pkg} must be a string.")

if (rlang::is_empty(pkg)) {
Expand Down Expand Up @@ -176,7 +176,7 @@ get_pkg_dependencies <- function(pkg = packageName(), lib.loc = NULL) {
#' @inheritParams check_pkg_installed
#' @keywords internal
#' @noRd
get_min_version_required <- function(pkg, ref = packageName(), lib.loc = NULL) {
get_min_version_required <- function(pkg, ref = utils::packageName(), lib.loc = NULL) {
if (!is.character(ref) && !is.null(ref)) cli::cli_abort("{.arg ref} must be a string.")

# if no package reference, return a df with just the pkg names
Expand Down
Loading