3

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:

#!/bin/sh
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
exit

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

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Josh Smith
  • 14,674
  • 18
  • 72
  • 118
  • Would that be that git doesn't know where to find those commands? Try specifying full paths to those binaries, rather than just stating the commands themselves. – favoretti Dec 22 '11 at 01:10
  • @favoretti Good idea, but still didn't work. I tested them with `/usr/bin/readyjs` which worked on the command line just fine, but failed in the hook. – Josh Smith Dec 22 '11 at 01:14

1 Answers1

12

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

chmod +x .git/hooks/pre-commit
offby1
  • 6,767
  • 30
  • 45
  • 1
    Exactly right. Now if your psychic powers could tell me why the hook is not executable by default when doing `git commit`. – Josh Smith Dec 22 '11 at 01:53
  • 2
    well, because you created that file yourself and new files are created with permissions specified by the mounted file systems file mode creation mask (umask) which should never create new files with the executable flag because most files are not :) – c089 Dec 26 '12 at 13:22
  • The follow-up (Stack Overflow) question is *[Why is my Git pre-commit hook not executable by default?](https://stackoverflow.com/questions/8598639/).* – Peter Mortensen Nov 24 '21 at 20:22