Skip to content

Instantly share code, notes, and snippets.

@drichert
Created April 27, 2011 21:18
Show Gist options
  • Save drichert/945238 to your computer and use it in GitHub Desktop.
Save drichert/945238 to your computer and use it in GitHub Desktop.
git post-checkout hook for compressing javascript (via uglifyjs)
#!/bin/bash
branch=$(git symbolic-ref -q HEAD |sed 's/refs\/heads\///')
gitroot=$(git rev-parse --show-toplevel)
jsdir="js"
targetdir="$gitroot/$jsdir"
files=$(find $targetdir -maxdepth 1 -type f -name '*.js' ! \( -name '*.min.js' \))
echo -n "Uglifying javascript... "
for f in $files; do
uglifyjs $f > $(echo $f |sed 's/\(\.js\)$/\.min\1/')
done
echo "done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment