R/load.R

Defines functions load

Documented in load

#' Load Jetpack
#'
#' @return No return value
#' @export
#' @keywords internal
load <- function() {
  dir <- findDir(getwd())

  if (is.null(dir)) {
    stopNotPackified()
  }

  tryCatch({
    configureRenv({
      setupEnv(dir)

      # must source from virtualenv directory
      # for RStudio for work properly
      wd <- getwd()
      on.exit(setwd(wd))
      setwd(renvProject())

      quietly(source("renv/activate.R"))
    })
  }, error=function(e) {
    args <- commandArgs(trailingOnly=TRUE)
    migrating <- !interactive() && identical(args, "migrate")
    if (!migrating) {
      if (interactive()) {
        stop(e)
      } else {
        message(conditionMessage(e))
        quit()
      }
    }
  })

  invisible()
}

Try the jetpack package in your browser

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

jetpack documentation built on Oct. 31, 2022, 5:07 p.m.