Skip to content

Commit

Permalink
add pre-commit hook
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Nov 25, 2016
1 parent e0ab042 commit ea61d98
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ After cloning the repo, run:
$ npm install
```

If you are on a Unix-like system, optionally install the Git pre-commit hook with:

``` bash
$ npm run install:hooks
```

This will run Flow and ESLint on changed files before each commit.

### Commonly used NPM scripts

``` bash
Expand Down
7 changes: 7 additions & 0 deletions build/git-hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

files_to_lint=$(git diff --cached --name-only --diff-filter=ACM | grep '\.js$')

if [ -n "$files_to_lint" ]; then
flow && NODE_ENV=production eslint $files_to_lint
fi
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
"sauce": "SAUCE=true karma start build/karma.sauce.config.js",
"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",
"release": "bash build/release.sh",
"release:weex": "bash build/release-weex.sh"
"release:weex": "bash build/release-weex.sh",
"install:hooks": "ln -fs ../../build/git-hooks/pre-commit .git/hooks/pre-commit"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit ea61d98

Please sign in to comment.