R/add_resource_path.R

Defines functions add_resource_path

Documented in add_resource_path

#' Add resource path
#'
#' @inheritParams shiny::addResourcePath
#' @param warn_empty Boolean. Default is `FALSE`.
#'     If TRUE display message if directory is empty.
#'
#' @importFrom shiny addResourcePath
#'
#' @export
#'
#' @return Used for side effects.
add_resource_path <- function(
  prefix,
  directoryPath,
  warn_empty = FALSE
) {
  list_f <- length(
    list.files(
      path = directoryPath
    )
  ) == 0

  if (list_f) {
    if (warn_empty) {
      warning("No resources to add from resource path (directory empty).")
    }
  } else {
    addResourcePath(prefix, directoryPath)
  }
}

Try the golem package in your browser

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

golem documentation built on June 7, 2023, 5:46 p.m.