forked from r-lib/devtools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuninstall.R
29 lines (25 loc) · 818 Bytes
/
uninstall.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#' Uninstall a local development package.
#'
#' Uses `remove.package` to uninstall the package.
#' To uninstall a package from a non-default library,
#' use [withr::with_libpaths()].
#'
#' @inheritParams install
#' @param unload if `TRUE` (the default), will automatically unload the
#' package prior to uninstalling.
#' @param ... additional arguments passed to [remove.packages()].
#' @export
#' @family package installation
#' @seealso [with_debug()] to install packages with debugging flags
#' set.
uninstall <- function(pkg = ".", unload = TRUE, quiet = FALSE, ...) {
pkg <- as.package(pkg)
if (unload && pkg$package %in% loaded_packages()$package) {
pkgload::unload(pkg$package)
}
if (!quiet) {
message("Uninstalling ", pkg$package)
}
remove.packages(pkg$package)
invisible(TRUE)
}