-
Notifications
You must be signed in to change notification settings - Fork 3
/
make.r
executable file
·38 lines (35 loc) · 1.23 KB
/
make.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
#!/usr/bin/Rscript
palettes <- local({
lastwd <- setwd('cmocean-python')
on.exit({system('git checkout main'); setwd(lastwd)})
lapply(setNames(nm = system('git tag -l --sort=version:refname', intern=T)), function(t) {
system(paste('git checkout', t))
rgb <- Sys.glob('cmocean/rgb/*-rgb.txt')
lapply(
setNames(rgb, sub('-rgb.txt', '', basename(rgb), fixed=T)),
read.table
)
})
})
names(palettes) <- sub('^v', '', names(palettes))
stopifnot(
`Expecting no changes in palettes after 2.0` = vapply(
palettes[(which(names(palettes) == '2.0')+1):length(palettes)],
identical, FALSE, palettes[['2.0']]
)
)
palettes <- palettes[1:(which(names(palettes) == '2.0'))]
save(palettes, file = 'R/sysdata.rda', version = 2, compress = 'xz')
# fix the version number to 3.6.3 to avoid binary changes in git
f <- xzfile('R/sysdata.rda', 'rb')
contents <- readBin(f, raw(), 1e7) # should be less than that
close(f)
h0 <- c( # see R Internals, 1.8 Serialization Formats
charToRaw('RDX2\nX\n'),
as.raw(c(0, 0, 0, 2, 0, unclass(getRversion())[[1]]))
)
stopifnot(length(contents) < 1e7, contents[seq_along(h0)] == h0)
contents[length(h0) - 2:0] <- as.raw(c(3, 6, 3))
f <- xzfile('R/sysdata.rda', 'wb', compression = 9)
writeBin(contents, f)
close(f)