R/use_rprofile.R

Defines functions use_rprofile

#' @keywords internal
use_rprofile <- function(project = ".") {
  proj <- normalizePath(project, mustWork = FALSE)

  withr::with_dir(proj, {
    file <- ".Rprofile"
    if (!file.exists(file)) {
      writeLines(
        con = file,
        text = c(
          "Sys.umask(\"0002\")",
          "if (interactive() && file.exists(\"~/.Rprofile\")) source(\"~/.Rprofile\")"
        )
      )
    } else {
      message(sprintf("\"%s\" already exists! Nothing was done!", file))
    }
  })
  invisible(TRUE)
}
umr1283/umr1283 documentation built on Nov. 27, 2022, 5:17 p.m.