Skip to content

Commit

Permalink
build: use cross-platform hook installation with shelljs
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jun 17, 2017
1 parent 610d1aa commit b5f08f3
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 8 deletions.
5 changes: 4 additions & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ After cloning the repo, run:
$ npm install
```

This would also run the `postinstall` script which will link git commit hooks if you are on a Unix-like system.
This will also run the `postinstall` script which links two git hooks:

- `pre-commit`: runs ESLint on staged files.
- `commit-msg`: validates commit message format (see below).

### Commiting Changes

Expand Down
8 changes: 8 additions & 0 deletions build/install-hooks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const { test, ln, chmod } = require('shelljs')

if (test('-e', '.git/hooks')) {
ln('-sf', '../../build/git-hooks/pre-commit', '.git/hooks/pre-commit')
chmod('+x', '.git/hooks/pre-commit')
ln('-sf', '../../build/git-hooks/commit-msg', '.git/hooks/commit-msg')
chmod('+x', '.git/hooks/commit-msg')
}
6 changes: 0 additions & 6 deletions build/install-hooks.sh

This file was deleted.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"release": "bash build/release.sh",
"release:weex": "bash build/release-weex.sh",
"release:note": "node build/gen-release-note.js",
"postinstall": "bash build/install-hooks.sh",
"postinstall": "node build/install-hooks.js",
"commit": "git-cz"
},
"repository": {
Expand Down Expand Up @@ -117,6 +117,7 @@
"rollup-watch": "^4.0.0",
"selenium-server": "^2.53.1",
"serialize-javascript": "^1.3.0",
"shelljs": "^0.7.8",
"typescript": "^2.3.4",
"uglify-js": "^3.0.15",
"webpack": "^2.6.1",
Expand Down
8 changes: 8 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4824,6 +4824,14 @@ shelljs@0.7.6, shelljs@^0.7.5:
interpret "^1.0.0"
rechoir "^0.6.2"

shelljs@^0.7.8:
version "0.7.8"
resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.7.8.tgz#decbcf874b0d1e5fb72e14b164a9683048e9acb3"
dependencies:
glob "^7.0.0"
interpret "^1.0.0"
rechoir "^0.6.2"

signal-exit@^3.0.0:
version "3.0.2"
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d"
Expand Down

0 comments on commit b5f08f3

Please sign in to comment.