#!/bin/sh
# First you will need to install jshint
# Enable this pre-commit hook by executing the following from the project root directory
# $ ln -s $PWD/scripts/pre-commit .git/hooks/pre-commit
if git diff --name-only --cached | grep -P '\.less$' ; then
	make less
fi
make jshint
if git diff --name-only --cached | grep -P '\.js$' ; then
	make qunit
fi
for file in `git diff --cached --name-only | grep ".png\$"`
do
	[ -f $file ] && echo "Crushing $file" &&  \
		pngcrush -rem alla -brute -reduce $file ${file%.png}.tmp | grep "filesize" || echo 'png was removed'
	[ -f $file ] && mv -f ${file%.png}.tmp $file || echo 'png was removed'
done
