-
Notifications
You must be signed in to change notification settings - Fork 4
/
minify.sh
executable file
·43 lines (30 loc) · 1.28 KB
/
minify.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
36
37
38
39
40
41
42
43
#!/bin/bash
###############################################################################
###############################################################################
EXTS=${1-'*'}
CURR=${2-'$(pwd)'}
OPTS=${3}
shopt -s nocasematch
###############################################################################
###############################################################################
if [[ $EXTS =~ ^\*|css$ ]] ; then
CSSs=$(tree -fi $CURR | grep '\.css$') ;
if [ "$CSSs" ] ; then
yuicompressor $OPTS -o '.css$:-min.css' $CSSs ;
MIN_CSSs=$(tree -fi $CURR | grep 'min\.css$') ;
for FN in $MIN_CSSs ; do mv $FN ${FN/'-min'/} ; done
fi
fi
###############################################################################
###############################################################################
if [[ $EXTS =~ ^\*|js$ ]] ; then
JSs=$(tree -fi $CURR | grep '\.js$')
if [ "$JSs" ] ; then
yuicompressor $OPTS -o '.js$:-min.js' $JSs ;
MIN_JSs=$(tree -fi $CURR | grep 'min\.js$') ;
for FN in $MIN_JSs ; do mv $FN ${FN/'-min'/} ; done
fi
fi
###############################################################################
###############################################################################
shopt -u nocasematch