Add optional library path to pacman
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
Package: Rpacman
|
Package: Rpacman
|
||||||
Type: Package
|
Type: Package
|
||||||
Title: Very simple package manager for R
|
Title: Very simple package manager for R
|
||||||
Version: 1.0.10
|
Version: 1.0.11
|
||||||
Date: 2022-05-31
|
Date: 2022-05-31
|
||||||
Authors@R: person("Craig", "Williams", email = "craig@avsdev.uk", role = c("aut", "cre"))
|
Authors@R: person("Craig", "Williams", email = "craig@avsdev.uk", role = c("aut", "cre"))
|
||||||
URL: https://avsdev.uk/R/Rpacman
|
URL: https://avsdev.uk/R/Rpacman
|
||||||
|
|||||||
10
R/activate.R
10
R/activate.R
@@ -6,11 +6,15 @@
|
|||||||
#' any user library paths
|
#' any user library paths
|
||||||
#'
|
#'
|
||||||
#' @export
|
#' @export
|
||||||
activate <- function(totalIsolation = FALSE) {
|
activate <- function(totalIsolation = FALSE, lib_path = NULL) {
|
||||||
check_pacman_dir()
|
check_pacman_dir()
|
||||||
|
pacman_lib_path <- file.path(getwd(), ".pacman/library")
|
||||||
|
if (!is.null(lib_path)) {
|
||||||
|
pacman_lib_path <- lib_path
|
||||||
|
}
|
||||||
if (totalIsolation) {
|
if (totalIsolation) {
|
||||||
environment(.libPaths)$.lib.loc <- c(file.path(getwd(), ".pacman/library"), .Library)
|
environment(.libPaths)$.lib.loc <- c(pacman_lib_path, .Library)
|
||||||
} else {
|
} else {
|
||||||
.libPaths(c(file.path(getwd(), ".pacman/library"), .libPaths()))
|
.libPaths(c(pacman_lib_path, .libPaths()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -60,11 +60,11 @@
|
|||||||
#'
|
#'
|
||||||
#' @import parallel
|
#' @import parallel
|
||||||
#' @export
|
#' @export
|
||||||
restore <- function(totalIsolation = FALSE, installOpts = list(Ncpus = parallel::detectCores()), parallel = FALSE) {
|
restore <- function(totalIsolation = FALSE, lib_path = NULL, installOpts = list(Ncpus = parallel::detectCores()), parallel = FALSE) {
|
||||||
old_opt <- options(stringsAsFactors = FALSE)
|
old_opt <- options(stringsAsFactors = FALSE)
|
||||||
on.exit(options(old_opt))
|
on.exit(options(old_opt))
|
||||||
|
|
||||||
activate(totalIsolation)
|
activate(totalIsolation, lib_path)
|
||||||
|
|
||||||
get_cran_repo()
|
get_cran_repo()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user