Aggregating and uglifying JavaScript in a Git pre-commit hook


I’m using ready.js to aggregate JavaScript files into an all.js file (without Google’s Closure Compiler) and am then using uglify-js to minify and obfuscate the code. I’d like to do all of this in a pre-commit hook.

However, I think I’m doing something wrong.

My .git/hooks/pre-commit file looks like this:

readyjs ~/Sites/backbone/js/javascripts/ ~/Sites/backbone/js/ --nojslint -o "underscore.js, backbone.js" --nocompiler
uglifyjs -nm -o ~/Sites/backbone/js/all.min.js ~/Sites/backbone/js/all.js
# Commit

Should I not be using simple Bash here? Is there something else I’m doing wrong? This step seems to be skipped entirely.


My psychic powers suggest that your script isn’t executable; try doing

chmod +x .git/hooks/pre-commit

Answered By – offby1

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published