1 | #!/bin/sh
|
2 | #
|
3 | # pre-commit: script to run checks on a working copy before commit
|
4 | #
|
5 | # To use, symlink it into .git/hooks:
|
6 | # ln -s ../../git-hooks/pre-commit .git/hooks
|
7 | #
|
8 |
|
9 | set -e
|
10 |
|
11 | # create a temp dir
|
12 | tmpdir=`mktemp -d`
|
13 | trap 'rm -rf "$tmpdir"' EXIT
|
14 |
|
15 | # get a copy of the index
|
16 | git checkout-index --prefix="$tmpdir/" -a
|
17 |
|
18 | # keep node_modules/.bin on the path
|
19 | rootdir=`git rev-parse --show-toplevel`
|
20 | export PATH="$rootdir/node_modules/.bin:$PATH"
|
21 |
|
22 | # now run our checks
|
23 | cd "$tmpdir"
|
24 | npm run lint
|