mirror of https://github.com/CrimsonTome/tldr.git
build-pdf: only build changed folders since last commit (#11773)
* build-pdf: only build changed folders since last commit * build-pdf: only determine language if needed * build-pdf: refactor the scriptpull/23/head
parent
93bf18f39a
commit
1de7b5a80b
|
@ -7,7 +7,6 @@ set -ex
|
||||||
function process_page {
|
function process_page {
|
||||||
pageDir="$1"
|
pageDir="$1"
|
||||||
folder=$(basename "${pageDir}")
|
folder=$(basename "${pageDir}")
|
||||||
language="${folder##*.}"
|
|
||||||
case $folder in
|
case $folder in
|
||||||
pages.bn | pages.ja | pages.ko | pages.ml | pages.ta | pages.th | pages.zh | pages.zh_TW)
|
pages.bn | pages.ja | pages.ko | pages.ml | pages.ta | pages.th | pages.zh | pages.zh_TW)
|
||||||
;;
|
;;
|
||||||
|
@ -15,14 +14,32 @@ function process_page {
|
||||||
python3 render.py "${pageDir}" -c solarized-light
|
python3 render.py "${pageDir}" -c solarized-light
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
language="${folder##*.}"
|
||||||
python3 render.py "${pageDir}" -c basic -o "tldr-book-${language}.pdf"
|
python3 render.py "${pageDir}" -c basic -o "tldr-book-${language}.pdf"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
function main {
|
function main {
|
||||||
for pageDir in ../../pages*; do
|
type="$1"
|
||||||
process_page "${pageDir}"
|
case $type in
|
||||||
|
"all")
|
||||||
|
pageDirs=(../../pages*)
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
changedFiles=$(git diff-tree --no-commit-id --name-only -r "$(git rev-parse HEAD)")
|
||||||
|
changedPageDirs=$(echo "$changedFiles" | awk -F/ '/^(pages[^\/]+|pages)\//{print $1}' | sort -u)
|
||||||
|
|
||||||
|
if [ -z "$changedPageDirs" ]; then
|
||||||
|
pageDirs=()
|
||||||
|
else
|
||||||
|
mapfile -t pageDirs <<< "$changedPageDirs"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
for pageDir in "${pageDirs[@]}"; do
|
||||||
|
process_page "../../${pageDir}"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,4 +47,4 @@ function main {
|
||||||
# MAIN
|
# MAIN
|
||||||
###################################
|
###################################
|
||||||
|
|
||||||
main
|
main $1
|
||||||
|
|
Loading…
Reference in New Issue