ari.lt/scripts/minhtml.sh
Ari Archer e5f674c19b Fix the minhtml script
Signed-off-by: Ari Archer <ari.web.xyz@gmail.com>
2022-10-01 04:05:36 +03:00

19 lines
473 B
Bash
Executable file

#!/usr/bin/env sh
set -e
main() {
if [ "$CI" ]; then
echo 'Minifying all HTML'
find . -not -ipath "./node_modules/*" -type f -name "*.html" \
-exec html-minifier --collapse-whitespace -o {}.min {} \; \
-exec rm {} \; \
-exec mv {}.min {} \; \
-exec sh -c "printf '\n\n%s\n' '<!-- source code @ /git -->' >>\"\$1\"" -- {} \;
else
echo 'Not minifying HTML in non-CI mode'
fi
}
main "$@"