-
Notifications
You must be signed in to change notification settings - Fork 0
/
.Rprofile
67 lines (53 loc) · 1.42 KB
/
.Rprofile
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
try(rprofile::load())
options(
lintr.linter_file = file.path(getwd(), 'dev', 'lintr', 'config')
)
local({
.pkgdir = getwd()
build = function () {
.write_license_file()
.rcmd('build', .pkgdir)
}
check = function (as_cran = TRUE) {
unlink(.bundle_path(), force = TRUE)
.rcmd('check', if (as_cran) '--as-cran', .bundle())
}
readme = function () {
devtools::document()
devtools::build_readme()
}
reload = function (export_all = FALSE) {
devtools::load_all(.pkgdir, export_all = export_all)
}
site = function () {
readme()
pkgdown::build_site()
}
.bundle = function () {
bundle = .bundle_path()
if (! file.exists(bundle)) build()
bundle
}
.bundle_path = function () {
desc = .desc()
file.path(.pkgdir, paste0(desc$Package, '_', desc$Version, '.tar.gz'))
}
.desc = function () {
d = as.list(read.dcf(file.path(.pkgdir, 'DESCRIPTION'))[1L, ])
d$Authors = eval(parse(text = d$`Authors@R`))
d
}
.r = function (...) {
rbin = file.path(R.home('bin'), 'R')
system2(rbin, shQuote(c(...)))
}
.rcmd = function (...) {
.r('CMD', ...)
}
.write_license_file = function () {
authors = toString(format(.desc()$Authors, c('given', 'family')))
license_text = sprintf('YEAR: 2024\nCOPYRIGHT HOLDER: %s', authors)
writeLines(license_text, file.path(.pkgdir, 'LICENSE'))
}
attach(mget(ls()), name = 'rprofile-utils')
})