-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrender.sh
More file actions
executable file
·40 lines (37 loc) · 785 Bytes
/
render.sh
File metadata and controls
executable file
·40 lines (37 loc) · 785 Bytes
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
#!/bin/bash
## Flag:
## -b to render coursebook using bookdown.
dobook=false
doslides=false
while getopts ":bs" opt; do
case $opt in
b)
dobook=true
;;
\?)
echo "invalid option: -${OPTARG}." >&2
;;
esac
done
folder=${!OPTIND}
## Throwing error for no argument (folder) provided.
if [ -z "$folder" ]; then
echo "ERROR: No folder given." >&2
exit 1
fi
## book
if [ "$dobook" = true ]; then
echo "Rendering book"
cd "$folder"
if [ -a index.Rmd ]; then
rmd_exists=true
else
rmd_exists=false
echo "ERROR: .Rmd doesn't exist." >&2
exit 2
fi
R -e "bookdown::render_book('index.Rmd',output_dir = './')" 2>&1 >/dev/null
mv _bookdown_files/docs_files/ ./
mv _bookdown_files/docs_cache/ ./
rmdir _bookdown_files/
fi