dev/run_dev.R

# Set options here
options(golem.app.prod = FALSE) # TRUE = production mode, FALSE = development mode

# Detach all loaded packages and clean your environment
golem::detach_all_attached()
rm(list=ls(all.names = TRUE))

# Document and reload your package
golem::document_and_reload()


# [M.E.] Debug utils
if (!getOption("golem.app.prod")){
  # 0. Instancie le chemin vers les 'checkpoints'
  checkpoint.path <- "./dev/checkpoints" # the working directory of the app is inst/app
  dir.create(checkpoint.path, showWarnings = F)
  # 1.1 Fonction de sauvegarde des variables
  checkpoint.save <- function(...){
    print(getwd())
    args <- list(...)
    print(names(args))
    for (arg_name in names(args))
      saveRDS(args[[arg_name]], file.path(checkpoint.path, arg_name))
  }
  # 1.2 Fonction pour restaurer toutes les variables du dossier checkpoint
  checkpoint.restore <- function(path = checkpoint.path){
    for (filename in list.files(path))
      assign(filename, readRDS(file.path(path, filename)), envir = .GlobalEnv)
  }
  # 1.3 Fonction pour vider le dossier checkpoint
  checkpoint.empty <- function(path = checkpoint.path){
    # TODO
  }
}

  
# Run the application
triangle.tlbx::run_app(dev_mode = TRUE)
MehdiChelh/triangle.tlbx documentation built on May 18, 2020, 3:14 a.m.