Fix CI yaml becoming invalid after container_scanning security job changing
[gitter.git] / build-scripts / selective-js-compile.sh
blob3b0b8c7c115d9ab0a8a2cdd06c80ea79d5305aea
1 #!/bin/bash
3 set -e
5 ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )"
7 generate_md5() {
8 if [[ -x $(which md5) ]]; then
9 md5 -q $1
10 else
11 md5sum $1 |cut -d\ -f1
15 for i in $(find $ROOT_DIR/public-processed/js -maxdepth 1 -name '*.js' ! -name '*.min.js'); do
16 min_file=${i%.js}.min.js
17 md5_file=$i.md5
18 md5_checksum=$(generate_md5 $i)
21 # A little bit of debugging
23 if [[ ! -f $md5_file ]]; then
24 echo "$i: $md5_file does not exist" >&2
25 else
26 if [[ ! -f $min_file ]]; then
27 echo "$i: $min_file does not exist" >&2
28 else
29 if [[ $md5_checksum != $(cat $md5_file) ]]; then
30 echo "$i Checksum mismatch $md5_checksum != $(cat $md5_file)" >&2
35 if [[ ! -f $md5_file ]] || [[ ! -f $min_file ]] || [[ $md5_checksum != $(cat $md5_file) ]]; then
36 echo $i needs updating >&2
38 rm -f $min_file ${min_file}.gz ${min_file}.map ${min_file}.map.gz
39 nice grunt manglejs --module $(basename $i) # & disabling async
40 echo $md5_checksum > $md5_file
41 else
42 echo "$i is compiled" >&2
44 done
46 # wait
48 for i in $(find $ROOT_DIR/public-processed/js -name '*.js' ! -name '*.min.js'); do
49 min_file=${i%.js}.min.js
50 if [[ ! -f $min_file ]]; then
51 echo Missing $min_file >&2
52 exit 1
54 done