Skip to content

Commit

Permalink
Update staticimports (#3872)
Browse files Browse the repository at this point in the history
  • Loading branch information
cpsievert committed Aug 15, 2023
1 parent 8b1d30a commit b054e45
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions R/shiny-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,11 @@ NULL
# since we call require(shiny) as part of loading the app.
#' @import methods
NULL


# For usethis::use_release_issue()
release_bullets <- function() {
c(
"Update static imports: `staticimports::import()`"
)
}
10 changes: 10 additions & 0 deletions R/staticimports.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,19 @@ get_package_version <- function(pkg) {

is_installed <- function(pkg, version = NULL) {
installed <- isNamespaceLoaded(pkg) || nzchar(system_file_cached(package = pkg))

if (is.null(version)) {
return(installed)
}

if (!is.character(version) && !inherits(version, "numeric_version")) {
# Avoid https://bugs.r-project.org/show_bug.cgi?id=18548
alert <- if (identical(Sys.getenv("TESTTHAT"), "true")) stop else warning
alert("`version` must be a character string or a `package_version` or `numeric_version` object.")

version <- numeric_version(sprintf("%0.9g", version))
}

installed && isTRUE(get_package_version(pkg) >= version)
}

Expand Down

0 comments on commit b054e45

Please sign in to comment.