Skip to content

Commit ea61d98

Browse files
committed
add pre-commit hook
1 parent e0ab042 commit ea61d98

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

.github/CONTRIBUTING.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@ After cloning the repo, run:
5959
$ npm install
6060
```
6161

62+
If you are on a Unix-like system, optionally install the Git pre-commit hook with:
63+
64+
``` bash
65+
$ npm run install:hooks
66+
```
67+
68+
This will run Flow and ESLint on changed files before each commit.
69+
6270
### Commonly used NPM scripts
6371

6472
``` bash

build/git-hooks/pre-commit

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
3+
files_to_lint=$(git diff --cached --name-only --diff-filter=ACM | grep '\.js$')
4+
5+
if [ -n "$files_to_lint" ]; then
6+
flow && NODE_ENV=production eslint $files_to_lint
7+
fi

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
"sauce": "SAUCE=true karma start build/karma.sauce.config.js",
4343
"bench:ssr": "npm run build:ssr && NODE_ENV=production node benchmarks/ssr/renderToString.js && NODE_ENV=production VUE_ENV=server node benchmarks/ssr/renderToStream.js",
4444
"release": "bash build/release.sh",
45-
"release:weex": "bash build/release-weex.sh"
45+
"release:weex": "bash build/release-weex.sh",
46+
"install:hooks": "ln -fs ../../build/git-hooks/pre-commit .git/hooks/pre-commit"
4647
},
4748
"repository": {
4849
"type": "git",

0 commit comments

Comments
 (0)