Permalink
Browse files

A handy hook script

  • Loading branch information...
1 parent 90101c0 commit 69079a2f9aaba31281e3bfad8cd5906a9cd210fd @richvdh richvdh committed Apr 14, 2016
Showing with 24 additions and 0 deletions.
  1. +24 −0 git-hooks/pre-commit
View
@@ -0,0 +1,24 @@
+#!/bin/sh
+#
+# pre-commit: script to run checks on a working copy before commit
+#
+# To use, symlink it into .git/hooks:
+# ln -s ../../git-hooks/pre-commit .git/hooks
+#
+
+set -e
+
+# create a temp dir
+tmpdir=`mktemp -d`
+trap 'rm -rf "$tmpdir"' EXIT
+
+# get a copy of the index
+git checkout-index --prefix="$tmpdir/" -a
+
+# keep node_modules/.bin on the path
+rootdir=`git rev-parse --show-toplevel`
+export PATH="$rootdir/node_modules/.bin:$PATH"
+
+# now run our checks
+cd "$tmpdir"
+npm run lint

0 comments on commit 69079a2

Please sign in to comment.