Created
July 15, 2012 06:25
-
-
Save mikeda/3115389 to your computer and use it in GitHub Desktop.
inotify-tools使ってJavaScriptが更新されたら自動的にYUI-Compresserで圧縮するスクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
MONITOR_DIR="/tmp/js" | |
OUTPUT_DIR="/tmp/min-js" | |
YUIC_JAR="~/tool/yuicompressor/build/yuicompressor-2.4.7.jar" | |
YUIC_OPTS="--charset utf-8" | |
inotifywait -m -e modify --format %w%f -r $MONITOR_DIR | egrep --line-buffered '\.(js|css)$' | \ | |
while read js;do | |
min_js=`echo $js | sed "s|$MONITOR_DIR|$OUTPUT_DIR|"` | |
min_js_dir=`dirname $min_js` | |
mkdir -p $min_js_dir | |
java -jar $YUIC_JAR $YUIC_OPTS -o $min_js $js | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment