Last active
February 23, 2018 13:57
-
-
Save yonicd/2af049efe7af2f6e599619a35b7d17fe to your computer and use it in GitHub Desktop.
install R packages from github and keep the source install file
This file contains 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
remotes_patch <- function(destdir=getwd()){ | |
#patch install_remote | |
install_remote_keep_source <- remotes:::install_remote | |
install_remote_body <- body(install_remote_keep_source) | |
install_remote_body[[6]] <- quote(on.exit({ | |
l <- list(...) | |
devtools::build(source,path = eval(enquote(l$destdir))) | |
unlink(source, recursive = TRUE) | |
}, add = TRUE)) | |
body(install_remote_keep_source) <- install_remote_body | |
#patch install_remotes | |
install_remotes_keep_source <- remotes:::install_remotes | |
install_remotes_body <- body(install_remotes_keep_source) | |
install_remotes_body[[2]] <- quote(invisible(vapply(remotes, install_remote_keep_source, | |
..., FUN.VALUE = logical(1)))) | |
body(install_remotes_keep_source) <- install_remotes_body | |
#patch install_github | |
install_github_keep_source <- remotes::install_github | |
install_github_body <- body(install_github_keep_source) | |
install_github_body[[3]] <- quote(install_remotes_keep_source(remotes, ...)) | |
body(install_github_keep_source) <- install_github_body | |
#assign back to .GlobalEnv | |
assign('install_remote_keep_source',value = install_remote_keep_source,envir = .GlobalEnv) | |
assign('install_remotes_keep_source',value = install_remotes_keep_source,envir = .GlobalEnv) | |
assign('install_github_keep_source',value = install_github_keep_source,envir = .GlobalEnv) | |
} | |
#example | |
#remotes_patch() | |
#install_github_keep_source('metrumresearchgroup/vcs',destdir='~/projects/test/new') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment