-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathdockerignore.R
69 lines (64 loc) · 1.24 KB
/
dockerignore.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#' Create a dockerignore file
#'
#' @param path Where to write the file
#'
#' @return The path to the `.dockerignore` file, invisibly.
#' @export
#' @importFrom fs path file_exists file_create
#' @importFrom cli cat_bullet
#'
#' @export
#'
#' @examples
#' \dontrun{
#' docker_ignore_add()
#' }
docker_ignore_add <- function(path) {
path_di <- fs::path(
path,
".dockerignore"
)
if (!fs::file_exists(
path_di
)) {
fs::file_create(path_di)
write_ignore <- function(content) {
write(content, path_di, append = TRUE)
}
for (i in c(
".RData",
".Rhistory",
".git",
".gitignore",
"manifest.json",
"rsconnect/",
".Rproj.user"
)) {
write_ignore(i)
}
path_ri <- fs::path(
path,
".Rbuildignore"
)
if (fs::file_exists(
path_ri
)) {
write(
"^\\.dockerignore$",
path_ri,
append = TRUE)
cat_bullet(
".dockerignore added to the .Rbuildignore file.",
bullet = "info",
bullet_col = "green"
)
}
} else {
cat_bullet(
".dockerignore already present, skipping its creation.",
bullet = "bullet",
bullet_col = "red"
)
}
return(invisible(path_di))
}