Browse Source

add pre-commit hook

dev
Evan You 8 years ago
parent
commit
ea61d9878f
  1. 8
      .github/CONTRIBUTING.md
  2. 7
      build/git-hooks/pre-commit
  3. 3
      package.json

8
.github/CONTRIBUTING.md

@ -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

7
build/git-hooks/pre-commit

@ -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
package.json

@ -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",

Loading…
Cancel
Save