Skip to content

Commit

Permalink
fix edge cases where there are more than one grep matches (e.g. packa…
Browse files Browse the repository at this point in the history
…ges boot and bootES) and when there is a required version for the first package of the Suggests list
  • Loading branch information
rempsyc committed Aug 13, 2023
1 parent 2872ad4 commit 96483a7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions R/check_if_installed.R
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,13 @@ print.check_if_installed <- function(x, ...) {
suggests_field <- utils::packageDescription(pkg, fields = "Suggests")
suggests_list <- unlist(strsplit(suggests_field, ",", fixed = TRUE))
out <- lapply(dep, function(x) {
dep_string <- grep(paste0("\n", x), suggests_list, value = TRUE, fixed = TRUE)
dep_string <- grep(x, suggests_list, value = TRUE, fixed = TRUE)
dep_string <- dep_string[which.min(nchar(dep_string))]
dep_string <- unlist(strsplit(dep_string, ">", fixed = TRUE))
gsub("[^0-9.]+", "", dep_string[2])
})
out <- unlist(out)
if (all(is.na(out))) {
out <- NULL
}
out
unlist(out)
}

0 comments on commit 96483a7

Please sign in to comment.