Skip to content

Commit

Permalink
Return version and all licence columns
Browse files Browse the repository at this point in the history
  • Loading branch information
hsonne committed May 5, 2024
1 parent 96c57c5 commit 2a518bf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
14 changes: 8 additions & 6 deletions R/getPackageLicences.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,25 @@
#' @param packages names of (installed) packages
#' @param db optional. Package database, similar to what is returned by
#' \code{\link[utils]{installed.packages}}. Default:
#' \code{as.data.frame(installed.packages())}
#' \code{installed.packages()}
#' @return data frame
#' @importFrom utils installed.packages
#' @export
getPackageLicences <- function(
packages,
db = as.data.frame(utils::installed.packages())
db = utils::installed.packages()
)
{
#kwb.utils::assignPackageObjects("kwb.package");stop.on.error = FALSE
#`%>%` <- magrittr::`%>%`
#db <- kwb.utils:::get_cached("package_db")
#packages <- db$Package

colnames(db) <- tolower(colnames(db))
licence_fields <- intersect(colnames(db), c("licence", "license"))
stopifnot(length(licence_fields) == 1L)
db <- as.data.frame(db)
names(db) <- gsub("license", "licence", tolower(names(db)))

licence_fields <- grep("^licence", names(db), value = TRUE)
stopifnot(length(licence_fields) > 0L)

backbone <- data.frame(
package = packages,
Expand All @@ -30,7 +32,7 @@ getPackageLicences <- function(

result <- backbone %>%
merge(
y = db[, c("package", licence_fields)],
y = selectColumns(db, c("package", "version", licence_fields)),
by = "package",
all.x = TRUE
) %>%
Expand Down
4 changes: 2 additions & 2 deletions man/getPackageLicences.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2a518bf

Please sign in to comment.