-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildall.R
executable file
·41 lines (37 loc) · 1.46 KB
/
buildall.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
#!/usr/bin/Rscript
library(methods)
library(rmarkdown)
library(nat)
library(flycircuit)
data_dir=getOption('flycircuit.datadir')
stopifnot(!is.null(data_dir))
if(!file.exists(file.path(data_dir, 'dpscanon.rds'))) {
## save ourselves a lot of time by pre-fetching the neuron data we need
# first download to temp location
tf=tempfile(fileext = '.zip')
# nb curl required for https, -L follows github redirect
download.file("https://github.com/jefferislab/dpscanon/archive/master.zip", tf,
method = 'curl', extra="-L")
# unzip to data dir
unzip(tf, exdir = data_dir)
# move files up one level
ziprd=file.path(data_dir,'dpscanon-master')
files_to_move=dir(ziprd, full.names = TRUE)
file.rename(files_to_move, file.path(data_dir, basename(files_to_move)))
}
root_dir <- getwd()
rmarkdown_files <- dir(normalizePath("fig"), pattern=".Rmd", recursive=TRUE, full.names = T)
built_files <- sapply(rmarkdown_files, function(x) { setwd(dirname(x)); render(basename(x), envir=globalenv()) })
# built_files will not exist if a file failed to build
if(!exists("built_files")) quit(status=1) else {
# make a zip file that will be uploaded to github
# note use of -j option to junk paths so that .html files are at the
# root of the zip file
setwd(root_dir)
message("Creating figures.zip in: ", root_dir)
rval=zip('figures.zip', built_files, flags='-r9Xj')
message("zip return value: ", rval)
message("zip info:")
nat.utils::zipinfo("figures.zip")
quit(status=0)
}