From 2240b34564b2598d74c5afafc84dd3dc13b54625 Mon Sep 17 00:00:00 2001 From: BBaoVanC Date: Sat, 12 Jun 2021 20:31:14 -0500 Subject: [PATCH] Add Makefile and use GNU parallel in compress.sh --- Makefile | 8 ++++++++ compress.sh | 23 ++++++++++++----------- 2 files changed, 20 insertions(+), 11 deletions(-) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f6bff2d --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ +all: public + +clean: + rm -rf public/ + +public: + hugo + ./compress.sh diff --git a/compress.sh b/compress.sh index 9134415..ca5cf48 100755 --- a/compress.sh +++ b/compress.sh @@ -2,17 +2,18 @@ files=$(find public/ -name "*.html" -o -name "*.xml" -o -name "*.css" -o -name "*.js") -for f in $files; do - ( gzip -fnk "$f" && echo "GZIP $f" ) & -done +gz() { + echo "GZIP $1" + gzip -fnk $1 +} -wait -echo "gzip done, starting brotli" +br() { + echo "BROTLI $1" + brotli -fZk $1 +} +export -f gz +export -f br -for f in $files; do - ( brotli -fZk "$f" && echo "BROTLI $f" ) & -done - -wait -echo "broli done" +parallel $@ gz {} <<< $files +parallel $@ br {} <<< $files