[Embed Files] Add exit code 1 when minify failed

This commit is contained in:
Saverio Cisternino
2018-11-28 13:26:24 +01:00
parent 12852c39d6
commit 52c1e1243e
+22 -5
View File
@@ -9,18 +9,35 @@
#
# See: https://github.com/letscontrolit/ESPEasy/issues/1671#issuecomment-415144898
cd static
outputfile="$(pwd)/data_h_temp"
rm $outputfile
function minify_html_css {
file=$1
curl -X POST -s --data-urlencode "input@$file" http://html-minifier.com/raw > /tmp/converter.temp
post_To http://html-minifier.com/raw $file
}
function minify_js {
file=$1
curl -X POST -s --data-urlencode "input@$file" https://javascript-minifier.com/raw > /tmp/converter.temp
post_To https://javascript-minifier.com/raw $file
}
function post_To {
url=$1
file=$2
RESPONSE=/tmp/response.txt
HEADERS=/tmp/headers.txt
curl -X POST -s --data-urlencode "input@$file" $url -D $HEADERS -o $RESPONSE
status=$(cat $HEADERS | grep '^HTTP/1' | tail -1 | awk '{print $2}')
if [[ "$status" == "200" ]]; then
cat $RESPONSE > /tmp/converter.temp
rm $RESPONSE
rm $HEADERS
else
echo "can not minify $file error $status"
exit 1
fi
}
function minify_svg {
@@ -43,7 +60,7 @@ function constFileName {
}
cd static
file_list=$(find . -type f)
for file in $file_list; do
@@ -79,4 +96,4 @@ for file in $file_list; do
echo ""
sleep 1
done
cd ..