Created
March 1, 2021 15:07
-
-
Save wrathematics/ccf6bf366279e099563e69e56b4fde59 to your computer and use it in GitHub Desktop.
Install (from) GitHub With Sub-Modules
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' ighwsm | |
#' Install (from) GitHub With Sub-Modules. Use when | |
#' \code{remotes::install_github()} fails. | |
#' | |
#' @details | |
#' Wrapper around \code{system()}. | |
#' | |
#' @param repo | |
#' GH repo of the usual form: \code{name/project}. | |
#' @param save_clone | |
#' Should the \code{git clone} tree be saved? | |
#' @param verbose | |
#' Should clone/install info be printed? | |
#' @param install_args | |
#' Additional arguments passed to \code{R CMD INSTALL}. | |
ighwsm = function(repo, save_clone=FALSE, verbose=FALSE, install_args="") | |
{ | |
verbose = isTRUE(verbose) | |
path = paste0("/tmp/", basename(repo)) | |
if (dir.exists(path)) | |
{ | |
if (verbose) | |
cat(paste0("* dir already exists at path=", path, " skipping\n")) | |
} | |
else | |
{ | |
if (verbose) | |
cat(paste0("* cloning into path=", path, "\n")) | |
cmd = paste0("cd /tmp && git clone --recurse-submodules https://github.com/", repo, ".git") | |
system(cmd, ignore.stdout=verbose) | |
} | |
if (verbose) | |
cat(paste0("* cloning into path=", path, "\n")) | |
cmd = paste("R CMD INSTALL", install_args, path) | |
ret = system(cmd, ignore.stdout=!verbose, ignore.stderr=!verbose) | |
if (!isTRUE(save_clone)) | |
unlink(path) | |
invisible(!as.logical(ret)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment