diff --git a/NEWS.md b/NEWS.md index 2eb04d7cb..898572333 100644 --- a/NEWS.md +++ b/NEWS.md @@ -52,6 +52,10 @@ environment variable or the `pkg_http_retry` option to `FALSE` to disable retries. +* Length checks for `pkg` are improved for `pkg_status()`, `pkg_deps()`, + `pkg_deps_tree()`, `pkg_deps_explain()`, and `pkg_install()` (#333, #716, + https://github.com/r-lib//pkgdepends/issues/449, @jmbarbone) + # pak 0.10.0 * pak now supports Posit Package Manager's Sigle Sign-On authentication. diff --git a/R/deps-explain.R b/R/deps-explain.R index 817dd46d2..39f33764e 100644 --- a/R/deps-explain.R +++ b/R/deps-explain.R @@ -27,7 +27,7 @@ #' ``` pkg_deps_explain <- function(pkg, deps, upgrade = TRUE, dependencies = NA) { - stopifnot(length(pkg == 1) && is.character(pkg)) + stopifnot(length(pkg) == 1L, is.character(pkg)) remote( function(...) { get("pkg_deps_explain_internal", asNamespace("pak"))(...) diff --git a/R/package.R b/R/package.R index 339e477c2..83d400fcf 100644 --- a/R/package.R +++ b/R/package.R @@ -78,6 +78,7 @@ pkg_install <- function( ask = interactive(), dependencies = NA ) { + stopifnot(length(pkg) > 0L) start <- Sys.time() lib <- lib %||% lib_default() @@ -173,7 +174,7 @@ pkg_install_do_plan <- function(proposal) { #' ``` pkg_status <- function(pkg, lib = NULL) { - stopifnot(length(pkg == 1) && is.character(pkg)) + stopifnot(length(pkg) > 0L, is.character(pkg)) lib <- lib %||% lib_default() load_extra("pillar") @@ -237,7 +238,7 @@ pkg_remove_internal <- function(pkg, lib = NULL) { #' ``` pkg_deps <- function(pkg, upgrade = TRUE, dependencies = NA) { - stopifnot(is.character(pkg)) + stopifnot(length(pkg) > 0L, is.character(pkg)) load_extra("pillar") remote( function(...) { @@ -290,7 +291,7 @@ pkg_deps_internal2 <- function(pkg, upgrade, dependencies) { #' ``` pkg_deps_tree <- function(pkg, upgrade = TRUE, dependencies = NA) { - stopifnot(length(pkg == 1) && is.character(pkg)) + stopifnot(length(pkg) > 0L, is.character(pkg)) ret <- remote( function(...) { get("pkg_deps_tree_internal", asNamespace("pak"))(...)