R/progress-bars.R

Defines functions should_show_progress_bar

should_show_progress_bar <- function() {
  # Option takes precedence
  opt <- getOption("pkg.show_progress", NULL)
  if (!is.null(opt)) return(isTRUE(opt))

  # FALSE on CI, this should be in cli, probably
  if (Sys.getenv("CI", "") != "") return(FALSE)

  # FALSE in knitr, this should be in cli, probably
  if (isTRUE(getOption("knitr.in.progress"))) return(FALSE)

  # FALSE in testthat as well, this should NOT be in cli, maybe
  if (identical(Sys.getenv("TESTTHAT"), "true")) return(FALSE)

  # Otherwise trust cli
  cli::is_dynamic_tty()
}
r-lib/pkgdepends documentation built on April 28, 2024, 3:23 a.m.