Skip to content

Commit

Permalink
chore: Add pre-commit hook via ghooks so it can be shared
Browse files Browse the repository at this point in the history
  • Loading branch information
yamikuronue committed Dec 19, 2016
1 parent 46ccb74 commit 9011c5a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"chai": "^3.5.0",
"eslint": "^3.12.1",
"eslint-plugin-babel": "^4.0.0",
"ghooks": "^1.3.2",
"karma": "^1.3.0",
"karma-chai": "^0.1.0",
"karma-mocha": "^1.3.0",
Expand All @@ -40,5 +41,10 @@
"debug/index.js": "browser.js",
"debug/debug.js": "debug.js"
}
},
"config": {
"ghooks": {
"pre-commit": "scripts/precommit.sh"
}
}
}
29 changes: 29 additions & 0 deletions scripts/precommit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".

# Stash anything not being committed
git stash -q --keep-index

echo
echo "Generating dist"
echo
# Make the dist files
make dist
echo
echo
echo "Distribution generation complete"
echo
echo "Adding updated files to commit"
echo
# add them
git add dist/
git add -u dist/

# Restore uncommitted changes
git stash pop -q

0 comments on commit 9011c5a

Please sign in to comment.