diff --git a/src/main/webapp/static/themes/compiletheme.sh b/src/main/webapp/static/themes/compiletheme.sh index deb1da081b872e46a8325ef0790b229dc639fb78..bd0c3ab94b6cd5fcb26c3377a0a422282cc82eb4 100755 --- a/src/main/webapp/static/themes/compiletheme.sh +++ b/src/main/webapp/static/themes/compiletheme.sh @@ -17,6 +17,8 @@ export SASS_PATH=. # Configuration STYLE=compressed #STYLE=compact +#default update command for sass +UPDATECMD="--update" # Helper method to add theme to array searchThemes () { @@ -45,24 +47,54 @@ ie9ify () { # Helper method to compile the theme doCompile () { TARGET=$1 + UPDATE=$UPDATECMD if [ $1 = "." ]; then TARGET="light" + if [[ "--watch" == $UPDATECMD && ! -z $THEMES ]]; then UPDATE="--update"; fi fi echo "Compiling SASS: $TARGET $STYLE" sass --version - sass --style $STYLE --no-cache --update $TARGET:$TARGET --load-path light light/modules - echo "sass --style $STYLE --update $TARGET:$TARGET --load-path light light/modules" + sass --style $STYLE --no-cache $UPDATE $TARGET:$TARGET --load-path light light/modules + echo "sass --style $STYLE $UPDATE $TARGET:$TARGET --load-path light light/modules" [ $bless -eq 0 ] && ie9ify $TARGET echo "done" } +control_c () { + exit 130; +} + +while getopts ":fhw" opt; do + case $opt in + f) + UPDATECMD="--update --force" + ;; + w) + UPDATECMD="--watch" + ;; + [h?]) + echo "Usage: $0 [-fhw] <theme>" + echo " f Update and recompile all Sass files, even if the CSS file is newer" + echo " h Show this message" + echo " w Watch theme for changes" + exit 1 + ;; + esac +done + +shift $((OPTIND-1)) +THEMES=$1 + +# handle ctrl-c +trap control_c SIGINT + # check for blessc command needed for ie9 optimizations command -v blessc >/dev/null 2>&1 bless=$? -[ $bless -ne 0 ] && echo >&2 "Install blessc to optimize css for ie <= 9 (npm install -g bless)" +[ $bless -ne 0 ] && printf >&2 "\n\e[0;31mInstall blessc to optimize css for ie <= 9 (npm install -g bless)\e[0m\n\n" # Add themes to compile from given path doCompile "."; -searchThemes $1; +searchThemes $THEMES; echo "DONE"