-
Notifications
You must be signed in to change notification settings - Fork 127
Expand file tree
/
Copy path_render.R
More file actions
17 lines (16 loc) · 690 Bytes
/
Copy path_render.R
File metadata and controls
17 lines (16 loc) · 690 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
quiet = "--quiet" %in% commandArgs(FALSE)
formats = commandArgs(TRUE)
travis = !is.na(Sys.getenv('CI', NA))
library("methods")
# provide default formats if necessary
if (length(formats) == 0) formats = c(
'bookdown::pdf_book', 'bookdown::epub_book', 'bookdown::gitbook'
)
# render the book to all formats unless they are specified via command-line args
for (fmt in formats) {
cmd = sprintf("bookdown::render_book('index.Rmd', '%s', quiet = %s, clean = FALSE)", fmt, quiet)
res = bookdown:::Rscript(c('-e', shQuote(cmd)))
if (res != 0) stop('Failed to compile the book to ', fmt)
if (!travis && fmt == 'bookdown::epub_book')
bookdown::calibre('_book/bookdown.epub', 'mobi')
}