Created
March 18, 2013 22:38
-
-
Save dandorman/5191488 to your computer and use it in GitHub Desktop.
A pre-commit hook for compiling health-tracking JS.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# Compile health-tracking javascript if necessary. | |
if git rev-parse --verify HEAD >/dev/null 2>&1 | |
then | |
against=HEAD | |
else | |
# Initial commit: diff against an empty tree object | |
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 | |
fi | |
if test "$(git diff --cached --name-only $against | | |
grep public/javascripts/health-tracking)" | |
then | |
if [ $(which node) ] | |
then | |
echo "Compiling production health-tracking javascript." | |
/usr/bin/env node script/r.js -o script/health-tracking.build.js | |
/usr/bin/env node script/r.js -o script/health-tracking.mobile-blood-sugar-calendar.build.js | |
/usr/bin/env node script/r.js -o script/health-tracking.mobile-hba1c-graph.build.js | |
if [ $? -eq 0 ] | |
then | |
git add public/javascripts/health-tracking.js | |
git add public/javascripts/health-tracking-mobile-blood-sugar-calendar.js | |
git add public/javascripts/health-tracking-mobile-hba1c-graph.js | |
else | |
echo "There was an error compiling production health-tracking javascript." | |
exit 1 | |
fi | |
else | |
"Please install node to compile production health-tracking javascript." | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment