-
Notifications
You must be signed in to change notification settings - Fork 15
/
create_yml.R
40 lines (33 loc) · 982 Bytes
/
create_yml.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#' @title Create _sinewconfig.yml
#' @description Create _sinewconfig.yml file in project root directory
#' @return nothing
#' @examples
#' \dontrun{
#' create_yml()
#' }
#' @rdname create_yml
#' @export
#' @author Jonathan Sidi
#' @concept utility
#' @importFrom rstudioapi getActiveProject
create_yml <- function() {
if (is.null(rstudioapi::getActiveProject())) {
stop("Not in RStudio Project")
}
yml <- file.path(rstudioapi::getActiveProject(), "_sinewconfig.yml")
ignore <- file.path(rstudioapi::getActiveProject(), ".Rbuildignore")
no_ignore <- !file.exists(ignore)
if (!file.exists(yml)) {
file.create(yml)
message(yml, " created")
}
if (no_ignore) {
file.create(ignore)
message(ignore, " created")
}
current_ignore <- readLines(".Rbuildignore")
if (!any(grepl("\\^\\.\\*\\\\\\.yml\\$", current_ignore))) {
cat("^.*\\.yml$", file = ignore, sep = "\n", append = !no_ignore)
message("^.*\\.yml$ added to ", ignore)
}
}