R/install_deps.R

Defines functions install_deps

Documented in install_deps

#' Install dependencies of reports within
#'
#' This function can be used to install package dependencies based on the
#' reports within the factory.
#' 
#' @inheritParams compile_reports
#' @param update A logical indicating if packages which are already installed
#'   should be re-installed (`TRUE`); otherwise, only missing packages are
#'   installed; defaults to `FALSE`.
#' @param ... Arguments to be passed to `install.packages()`.
#' 
#' @seealso \code{\link{list_deps}} to list dependencies of packages
#' 
#' @export
install_deps <- function(factory = ".", update = FALSE, ...) {

  pkg_to_install <- list_deps(factory = factory, missing = !update)

  if (length(pkg_to_install) > 0L) {
    utils::install.packages(pkg_to_install, ...)
  } else {
    message("All packages needed are already installed.")
  }
}
tjtnew/reportfactory documentation built on Dec. 31, 2020, 8:40 a.m.