Ajout script build.sh/dev.sh
This commit is contained in:
parent
a4a9789d63
commit
9bbfdafb5c
4 changed files with 357 additions and 325 deletions
|
|
@ -1,6 +1,35 @@
|
|||
#! /usr/bin/env bash
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
basedir="$(dirname "$0")"
|
||||
basedir="$(realpath "$basedir")"
|
||||
cd "$basedir"
|
||||
name="$(basename "$(pwd)")"
|
||||
|
||||
typst compile --root .. ./main.typ ./"$name".pdf
|
||||
if ! typst compile --root .. ./main.typ ./"$name".pdf; then
|
||||
echo "Failed to compile $name/main.typ. Please fix errors and run me again."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Compiled read mode. Now compiling print mode."
|
||||
|
||||
if ! command -v pdfbook2; then
|
||||
echo "ERROR: pdfbook2 not installed. Not compiling print mode."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
t="$(mktemp --suffix=.pdf)"
|
||||
typst compile --input format=booklet --root .. ./main.typ "$t"
|
||||
|
||||
# Need to be in the folder there for it to work, otherwise it
|
||||
# tries to rename from current partition to /tmp which of course fails
|
||||
parent="$(dirname "$t")"
|
||||
newFileName="$(basename "$t" .pdf)-book.pdf"
|
||||
newFile="$parent"/"$newFileName"
|
||||
cd "$parent"
|
||||
|
||||
pdfbook2 --paper=a4paper "$t" --no-crop --outer-margin=0 --inner-margin=0 --top-margin=0 --bottom-margin=0
|
||||
|
||||
cd "$basedir"
|
||||
newFinalFile="$name"-book.pdf
|
||||
cp "$newFile" "$newFinalFile"
|
||||
echo "Booklet available in $newFinalFile"
|
||||
|
|
|
|||
Loading…
Reference in a new issue