Files
Rpacman/R/snapshot.R

24 lines
666 B
R

# Requires snapshot_create.R
# Requires snapshot_history.R
#' Save the current state of the project into the lock file as a snapshot
#'
#' @param installOpts list Installer options for use when installing CRAN
#' packages
#'
#' @return invisible return of the current snapshot
#' @export
snapshot_save <- function(installOpts = list(Ncpus = parallel::detectCores()), snapshot = NULL) {
if (is.null(snapshot)) {
snapshot <- snapshot_create(installOpts)
}
history <- snapshot_history()
history <- c(list(snapshot), history)
snapshot$history <- history
jsonlite::write_json(snapshot, "pacman.lock")
snapshot$history <- NULL
return(snapshot)
}