-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathentrypoint.sh
35 lines (29 loc) · 960 Bytes
/
entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
IFS=','
read -ra FILE_EXTENSIONS <<< "${2:-.js,.css,.html,.json}"
read -ra TOOLS <<< "${3:-brotli,gzip}"
depth=${4:-3}
deterministicCompression=${5:-false}
echo "Processing files in folder '$1' using maximum folder depth $depth"
for FILE_EXT in "${FILE_EXTENSIONS[@]}"
do
for TOOL in "${TOOLS[@]}"
do
case $TOOL in
gzip)
if [ "$deterministicCompression" = "true" ]
then
`find $1 -maxdepth $depth -type f -name "*$FILE_EXT" -exec gzip -k -f -n {} \;`
else
`find $1 -maxdepth $depth -type f -name "*$FILE_EXT" -exec gzip -k -f {} \;`
fi
;;
brotli)
`find $1 -maxdepth $depth -type f -name "*$FILE_EXT" -exec brotli -f {} \;`
;;
*)
echo "Invalid tool"
;;
esac
done
done