Skip to content

Instantly share code, notes, and snippets.

@magadanskiuchen
Created March 21, 2015 17:55
Show Gist options
  • Save magadanskiuchen/3f12d5e7260777fe0087 to your computer and use it in GitHub Desktop.
Save magadanskiuchen/3f12d5e7260777fe0087 to your computer and use it in GitHub Desktop.
A GIT post-merge hook to auto combine and minify all of your JavaScript files when merging a branch into "production"
current_branch="$(git rev-parse --abbrev-ref HEAD)";
if [[ $current_branch == 'production' ]]; then
find js -name *.js | xargs cat > js/combined.js
curl -X POST -s --data-urlencode 'input@js/combined.js' http://javascript-minifier.com/raw > js/combined.min.js
rm js/combined.js
git commit -a -m "[automated] combined and minified JS"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment