diff --git a/R/install_latest_version.R b/R/install_latest_version.R index 70776e6f8..b846d7b99 100644 --- a/R/install_latest_version.R +++ b/R/install_latest_version.R @@ -2,12 +2,14 @@ #' #' @description This function installs the latest version #' +#' @param test Flag for test +#' #' @return NULL #' #' @export #' #' @examples NULL -install_latest_version <- function() { +install_latest_version <- function(test = FALSE) { options(repos = c(CRAN = "https://cloud.r-project.org")) if (Sys.info()[["sysname"]] == "Windows") { message("You should install RTools if not already done") @@ -55,17 +57,19 @@ install_latest_version <- function() { ask = FALSE ) }, - error = function(err) { - if (Sys.getenv("RSTUDIO") == 1) { - if (!requireNamespace("rstudioapi", quietly = TRUE)) { - install.packages("rstudioapi") - } - rstudioapi::restartSession() - } else { - if (!requireNamespace("startup", quietly = TRUE)) { - install.packages("startup") + error = function(e) { + if (test == FALSE) { + if (Sys.getenv("RSTUDIO") == 1) { + if (!requireNamespace("rstudioapi", quietly = TRUE)) { + install.packages("rstudioapi") + } + rstudioapi::restartSession() + } else { + if (!requireNamespace("startup", quietly = TRUE)) { + install.packages("startup") + } + startup::restart() } - startup::restart() } } ) diff --git a/codemeta.json b/codemeta.json index 4836e59b9..01b7f9e4d 100644 --- a/codemeta.json +++ b/codemeta.json @@ -578,7 +578,7 @@ "SystemRequirements": null }, "keywords": ["metaboliteannotation", "chemotaxonomy", "scoringsystem", "naturalproducts", "computationalmetabolomics", "taxonomicdistance", "specializedmetabolome"], - "fileSize": "4377.05KB", + "fileSize": "4377.249KB", "citation": [ { "@type": "ScholarlyArticle", diff --git a/man/install_latest_version.Rd b/man/install_latest_version.Rd index 152284d54..cd1ab1b94 100644 --- a/man/install_latest_version.Rd +++ b/man/install_latest_version.Rd @@ -4,7 +4,10 @@ \alias{install_latest_version} \title{Install latest version} \usage{ -install_latest_version() +install_latest_version(test = FALSE) +} +\arguments{ +\item{test}{Flag for test} } \description{ This function installs the latest version diff --git a/tests/testthat/test-functions.R b/tests/testthat/test-functions.R index 6c021fd27..3fe567b4c 100644 --- a/tests/testthat/test-functions.R +++ b/tests/testthat/test-functions.R @@ -2,7 +2,7 @@ library(testthat) ## need to do all in one because of outputs needed in the same temp dir ## use fixtures instead in the future test_that("Test functions", { - install_latest_version() + install_latest_version(test = TRUE) setwd(fs::path_home(".tima")) ## Prepare parameters paths <- parse_yaml_paths()