Skip to content

Commit

Permalink
add a utility function to update a single package
Browse files Browse the repository at this point in the history
  • Loading branch information
yihui committed Jan 20, 2021
1 parent 8c2408e commit e1b2408
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions R/packages.R
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,12 @@ reinstall_from_cran = function(dry_run = TRUE, skip_github = TRUE) {
}

base_pkgs = function() rownames(installed.packages(priority = 'base'))

# update one package (from source by default)
pkg_update_one = function(pkg, type = 'source') {
opts = options(repos = c(CRAN = 'https://cran.r-project.org'))
on.exit(options(opts), add = TRUE)
if (is.null(pkgs <- old.packages(type = type)) || !pkg %in% rownames(pkgs)) return()
install.packages(pkg, pkgs[pkg, 'LibPath'], type = type, INSTALL_opts = '--no-staged-install')
NULL
}

0 comments on commit e1b2408

Please sign in to comment.