diff --git a/R/packages.R b/R/packages.R index 629635b..f63a266 100644 --- a/R/packages.R +++ b/R/packages.R @@ -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 +}