Last active
September 8, 2021 07:09
-
-
Save alex-gable/d18eef6081b0896ffadbc5450ded0345 to your computer and use it in GitHub Desktop.
update function that works with pak
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
update_pak <- function() { | |
`%>%` <- magrittr::`%>%` | |
pl <- pak::lib_status() %>% | |
dplyr::mutate(package_full = | |
dplyr::case_when( | |
dplyr::coalesce(repository, remotetype) == "CRAN" ~ package, | |
dplyr::coalesce(repository, remotetype) == "github" ~ | |
paste0(remoteusername, "/", remoterepo), | |
TRUE ~ NA_character_)) %>% | |
dplyr::filter(!is.na(package_full)) | |
ap <- tibble::as_tibble(utils::available.packages()) | |
cran_plu <- pl %>% | |
dplyr::filter(repository == "CRAN") %>% | |
dplyr::inner_join(ap, by = c(package = "Package")) %>% | |
dplyr::filter(version < Version) %>% | |
dplyr::pull(package) | |
gh_plu <- pl %>% | |
dplyr::filter(dplyr::coalesce(repository, remotetype) == "github") %>% | |
dplyr::pull(package_full) | |
pak::pkg_install(cran_plu, upgrade = TRUE) | |
pak::pkg_install(gh_plu, upgrade = TRUE) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
fails if a build fails, doesn't exit properly if nothing to update.