#!/bin/sh

set -e

if [ "x$1" = "x-v" -o "x$1" = "x--verbose" ] ; then
    VERBOSE="--verbose"
else
    VERBOSE=""
fi

for file in `find js -name '*.js' -not -name '*min.js'` ; do
    mkdir -p sources/`dirname $file`
    if [ ! -z "$VERBOSE" ] ; then
        echo "Compressing $file ..."
    fi
    yui-compressor --charset utf-8 $VERBOSE --type js $file > $file.tmp
    cp -a $file sources/$file
    mv $file.tmp $file
done
