Skip to content

Commit

Permalink
Expose package version info (#625)
Browse files Browse the repository at this point in the history
* Expose package version info

* Respond to review
  • Loading branch information
jennybc authored Nov 15, 2024
1 parent 6e40dec commit 4204091
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions crates/ark/src/modules/positron/package.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,29 @@
#' @export
.ps.rpc.is_installed <- .ps.is_installed

# Returns a list containing:
# * the version string if the package is installed and NULL otherwise
# * a logical indicating if package is installed at or above the minimum version
# This may seem weird, but it's impractical for positron-r to do version
# comparisons.
#' @export
.ps.rpc.packageVersion <- function(pkg, minimumVersion = NULL) {
installed <- system.file(package = pkg) != ""

if (installed) {
version <- utils::packageVersion(pkg)
list(
version = as.character(version),
compatible = is.null(minimumVersion) || version >= minimumVersion
)
} else {
list(
version = NULL,
compatible = FALSE
)
}
}

#' @export
.ps.rpc.install_packages <- function(packages) {
for (pkg in packages) {
Expand Down

0 comments on commit 4204091

Please sign in to comment.