R/try_save_all.R

Defines functions try_save_all

#' Try to save open files if \pkg{rextendr} is called from an IDE.
#'
#' Uses rstudio API (if available) to save modfied files.
#' Improves package development experience within RStudio.
#' @param quiet Logical scalar indicating whether the output should be quiet (`TRUE`)
#'   or verbose (`FALSE`).
#' @noRd
try_save_all <- function(quiet = FALSE) {
  if (requireNamespace("rstudioapi", quietly = TRUE) && rstudioapi::hasFun("documentSaveAll")) {
    rstudioapi::documentSaveAll()
    if (!isTRUE(quiet)) {
      cli::cli_alert_success("Saving changes in the open files.")
    }
  }
}

Try the rextendr package in your browser

Any scripts or data that you put into this service are public.

rextendr documentation built on July 9, 2023, 5:54 p.m.