From 787b58e58d71e0b09e1eb251072c6b51bd7e9ed4 Mon Sep 17 00:00:00 2001 From: Andrew Barr Date: Thu, 8 May 2014 08:56:07 -0500 Subject: [PATCH 1/3] add CNAME parameter to add CNAME file when publishing --- R/publishGitbook.R | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/R/publishGitbook.R b/R/publishGitbook.R index d270220..06ef362 100644 --- a/R/publishGitbook.R +++ b/R/publishGitbook.R @@ -10,14 +10,25 @@ #' @param repo the github repository. Should be of form username/repository #' @param out.dir location of the built gitbook. #' @param message commit message. +#' @param CNAME web address to be added to CNAME file on github for custom domain names #' #' @export publishGitbook <- function(repo, out.dir=paste0(getwd(), '/_book'), - message='Update built gitbook') { + message='Update built gitbook', + CNAME = "" + ) { test <- system('git --version', ignore.stderr=TRUE, ignore.stdout=TRUE, show.output.on.console=FALSE) if(test != 0) { stop('Git does not appear to be installed.')} - cmd <- paste0( + + + if(CNAME != ""){ + fileConn<-file("CNAME") + writeLines(CNAME, fileConn) + close(fileConn) + } + + cmd <- paste0( "cd ", out.dir, " \n", "git init \n", "git commit --allow-empty -m '", message,"' \n", From 87371a96caac28e3de4e758ebff63bc60d807f96 Mon Sep 17 00:00:00 2001 From: Andrew Barr Date: Thu, 8 May 2014 09:09:59 -0500 Subject: [PATCH 2/3] create CNAME in the _book dir --- R/publishGitbook.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/publishGitbook.R b/R/publishGitbook.R index 06ef362..998db29 100644 --- a/R/publishGitbook.R +++ b/R/publishGitbook.R @@ -23,7 +23,7 @@ publishGitbook <- function(repo, if(CNAME != ""){ - fileConn<-file("CNAME") + fileConn<-file(paste0(out.dir,"/CNAME")) writeLines(CNAME, fileConn) close(fileConn) } From 8b961b794bc48f42420652d6318f5bec6b6e7c33 Mon Sep 17 00:00:00 2001 From: Andrew Barr Date: Thu, 8 May 2014 09:19:25 -0500 Subject: [PATCH 3/3] updated documentation --- man/publishGitbook.Rd | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/man/publishGitbook.Rd b/man/publishGitbook.Rd index 1532dc9..ff06e21 100644 --- a/man/publishGitbook.Rd +++ b/man/publishGitbook.Rd @@ -3,7 +3,7 @@ \title{Publish the built gitbook to Github.} \usage{ publishGitbook(repo, out.dir = paste0(getwd(), "/_book"), - message = "Update built gitbook") + message = "Update built gitbook", CNAME = "") } \arguments{ \item{repo}{the github repository. Should be of form @@ -12,6 +12,9 @@ publishGitbook(repo, out.dir = paste0(getwd(), "/_book"), \item{out.dir}{location of the built gitbook.} \item{message}{commit message.} + + \item{CNAME}{web address to be added to CNAME file on + github for custom domain names} } \description{ Note that this is a wrapper to system \code{git} call.