-
Notifications
You must be signed in to change notification settings - Fork 276
/
generate-pdf
executable file
·57 lines (43 loc) · 1 KB
/
generate-pdf
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
#!/usr/bin/env bash
#
# Generate PDF
# Header
echo "Creating a PDF... if this fails check out the documentation at: https://toolchain.gitbook.com/ebook.html"
# NPM Install
npm install -g gitbook-cli svgexport
# Load the error code
ERROR_CODE=$?
# Check the shell for errors
if [ $ERROR_CODE -ne 0 ]; then
echo "ERROR! Failed to run npm install"
exit 1
fi
# Copy the files
cp docs/_sidebar.md docs/SUMMARY.md
# Load the error code
ERROR_CODE=$?
# Check the shell for errors
if [ $ERROR_CODE -ne 0 ]; then
echo "ERROR! Failed to run cp"
exit 1
fi
# Run the gitbook
gitbook pdf docs/ docs/book.pdf
# Load the error code
ERROR_CODE=$?
# Check the shell for errors
if [ $ERROR_CODE -ne 0 ]; then
echo "ERROR! Failed to run gitbook"
exit 1
fi
# Remove dead file
rm docs/SUMMARY.md
# Load the error code
ERROR_CODE=$?
# Check the shell for errors
if [ $ERROR_CODE -ne 0 ]; then
echo "ERROR! Failed to run rm"
exit 1
fi
# Footer
echo "Your PDF is at docs/book.pdf. Commit it to your repo if you'd like to."