Skip to content

Instantly share code, notes, and snippets.

@mikeda
Created July 15, 2012 06:25
Show Gist options
  • Save mikeda/3115389 to your computer and use it in GitHub Desktop.
Save mikeda/3115389 to your computer and use it in GitHub Desktop.
inotify-tools使ってJavaScriptが更新されたら自動的にYUI-Compresserで圧縮するスクリプト
#!/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