Skip to content

Commit

Permalink
in tlmgr_install(), check if the pkgs are really installed after `t…
Browse files Browse the repository at this point in the history
…lmgr install pkgs` via the stdout result of `tlmgr info pkgs` instead of the status code, because the status code is always 0 on Windows
  • Loading branch information
yihui committed Jan 15, 2020
1 parent 6efd215 commit 2f3abf3
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion R/tlmgr.R
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ tlmgr_install = function(pkgs = character(), usermode = FALSE, path = !usermode
res = 0L
if (length(pkgs)) {
res = tlmgr(c('install', pkgs), usermode, ...)
if (res != 0 || tl_list(pkgs, stdout = FALSE, stderr = FALSE, .quiet = TRUE) != 0) {
if (res != 0 || !check_installed(pkgs)) {
tlmgr_update(all = FALSE, usermode = usermode)
res = tlmgr(c('install', pkgs), usermode, ...)
}
Expand All @@ -121,6 +121,17 @@ tlmgr_install = function(pkgs = character(), usermode = FALSE, path = !usermode
invisible(res)
}

# check of certain LaTeX packages are installed: if installed, `tlmgr info pkgs`
# should return `pkgs`
check_installed = function(pkgs) {
if (length(pkgs) == 0) return(TRUE)
res = tryCatch(
tl_list(pkgs, stdout = TRUE, stderr = FALSE, .quiet = TRUE),
error = function(e) NULL, warning = function(e) NULL
)
identical(res, pkgs)
}

#' @rdname tlmgr
#' @export
tlmgr_remove = function(pkgs = character(), usermode = FALSE) {
Expand Down

0 comments on commit 2f3abf3

Please sign in to comment.