Skip to content

Instantly share code, notes, and snippets.

@shabbychef
Created May 30, 2015 18:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shabbychef/dd5bab25c76baae23f3b to your computer and use it in GitHub Desktop.
Save shabbychef/dd5bab25c76baae23f3b to your computer and use it in GitHub Desktop.
install_github only once ever.
library(git2r)
library(devtools)
library(drat)
install_github2 <- function(repo) {
dest <- tempfile()
dir.create(dest, recursive=TRUE)
# download
repo <- git2r::clone(paste0('https://github.com/',repo,'.git'),dest)
on.exit(unlink(dest), add = TRUE)
# install
devtools::install_local(dest)
# build
buildpath <- tempfile()
dir.create(buildpath, recursive=TRUE)
on.exit(unlink(buildpath), add = TRUE)
devtools::RCMD('build',c('--as-cran',dest),buildpath)
# drat
files <- dir(buildpath)
drat::insertPackage(file.path(buildpath,files[1]))
}
# try it:
#install_github2('cttobin/ggthemr')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment