Skip to content

Instantly share code, notes, and snippets.

@ghuntley
Forked from drichert/post-checkout
Created June 27, 2011 11:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ghuntley/1048696 to your computer and use it in GitHub Desktop.
Save ghuntley/1048696 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