# Helper functions -------------------------------------------------------------
.uninstall_local_package <- function(){
message("\n","Uninstalling previous package version")
try(remove.packages(.get_package_name()), silent = TRUE)
return(invisible())
}
.install_development_packages <- function(){
message("\n","Installing development tools")
.install.packages("tidyverse")
.install.packages("devtools")
.install.packages("testthat")
.install.packages("assertive")
.install.packages("covr")
.install.packages("callr")
}
.install_local_package <- function(){
message("\n","Installing the current package version")
.library("devtools")
devtools::install_local(
path = ".",
dependencies = TRUE,
upgrade = FALSE,
force = FALSE,
build = FALSE,
build_opts = "--no-multiarch --with-keep.source --no-build-vignettes",
Ncpus = parallel::detectCores(),
repos = "https://cloud.r-project.org"
)
}
.library <- function(package){
.install.packages(package)
library(package, character.only = TRUE)
}
.install.packages <- function(package){
if(isFALSE(package %in% rownames(utils::installed.packages())))
utils::install.packages(package,
repos = "https://cloud.r-project.org",
dependencies = TRUE,
Ncpus = parallel::detectCores()
)
}
.get_package_name <- function(){
return(gsub(".Rcheck$", "", basename(.getwd())))
}
.getwd <- function(){
path_project <- getwd()
while (length(grep("test", path_project))>0) path_project <- dirname(path_project)
return(path_project)
}
# Install local package --------------------------------------------------------
.uninstall_local_package()
.install_development_packages()
.install_local_package()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.