R/build_gitignore.R

#' Build .gitignore
#' @description Generates a .gitignore file and adds it to the repo.
#' @param dir The location to create the .gitignore.  Defaults to working directory.
#' @examples
#' build_gitignore()
#' @export

build_gitignore <- function(dir = getwd()) {

  # builds the gitignore in the given workind directory

  to_ignore <- c(".DS_Store",
                 ".Rhistory",
                 ".Rprofile",
                 ".Rapp.history",
                 ".RData",
                 "*-Ex.R",
                 "/*.tar.gz",
                 "/*.Rcheck/",
                 ".Rproj.user/",
                 "vignettes/*.html",
                 "vignettes/*.pdf",
                 ".httr-oauth",
                 "/*_cache/",
                 "/cache/",
                "*.utf8.md",
                "*.knit.md",
                ".Rproj.user",
                "*.Rda",
                "*.pdf",
                "*.csv",
                "*.html",
                "*.DS_Store",
                "/*.DS_Store",
                "*/*.DS_Store")

  fileConn <- file(file.path(dir, ".gitignore"))
  writeLines(text = to_ignore, con = fileConn)
  close(fileConn)
}
jrminter/minterbrand documentation built on May 26, 2019, 5:41 p.m.