-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcran_00_interactive.R
More file actions
65 lines (61 loc) · 1.71 KB
/
Copy pathcran_00_interactive.R
File metadata and controls
65 lines (61 loc) · 1.71 KB
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
local({
make_r_script_options <- function() {
# this can be run locally to update r_script_options
stopifnot("cran_00_interactive.R" %in% dir())
r_script_options <- dir(pattern = "^cran_[0-9]+_")
this_script_name <- r_script_options[grepl("00", r_script_options)]
r_script_options <- setdiff(r_script_options, this_script_name)
lines <- readLines(this_script_name)
replace_range <- which(grepl("^ *# *%r_script_options", lines))
replace_lines <- c(
" r_script_options <- c(",
paste0(
" \"",
r_script_options,
"\"",
c(rep(",", length(r_script_options) - 1L), "")
),
" )"
)
lines <- c(
lines[seq_len(replace_range[1])],
replace_lines,
lines[replace_range[2]:length(lines)]
)
writeLines(lines, this_script_name)
}
# %r_script_options
r_script_options <- c(
"cran_01_check.R",
"cran_02_check_remotely.R",
"cran_03_misc.R",
"cran_04_prerelease.R",
"cran_05_release.R",
"cran_06_post_accept.R"
)
# %r_script_options
message(
"Select script to run:\n",
paste0(seq_along(r_script_options), ": ", r_script_options, "\n")
)
a <- ""
while (!a %in% seq_along(r_script_options)) {
a <- readline(": ")
}
a <- as.integer(a)
script_url <- paste0(
"https://raw.githubusercontent.com/FinnishCancerRegistry/r-package-dev-scripts/refs/heads/main/",
r_script_options[a]
)
script_lines <- readLines(script_url)
cat(script_lines, sep = "\n")
message("Run the script containing the above code? [y/n]")
a <- ""
while (!a %in% c("y", "n")) {
a <- readline(": ")
}
a <- a == "y"
if (a) {
source(script_url, encoding = "UTF-8", local = globalenv())
}
})