Skip to content

Commit 552593b

Browse files
docs: update husky hook adding (#3141)
1 parent 20122e8 commit 552593b

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

README.md

+15-10
Original file line numberDiff line numberDiff line change
@@ -104,18 +104,23 @@ yarn add husky --dev
104104
npx husky install
105105
# or
106106
yarn husky install
107+
```
107108

108-
# Add hook
109-
npx husky add .husky/commit-msg 'npx --no -- commitlint --edit "$1"'
110-
# Sometimes above command doesn't work in some command interpreters
111-
# You can try other commands below to write npx --no -- commitlint --edit $1
112-
# in the commit-msg file.
113-
npx husky add .husky/commit-msg \"npx --no -- commitlint --edit '$1'\"
114-
# or
115-
npx husky add .husky/commit-msg "npx --no -- commitlint --edit $1"
109+
### Add hook
116110

117-
# or
118-
yarn husky add .husky/commit-msg 'yarn commitlint --edit $1'
111+
```sh
112+
cat <<EEE > .husky/commit-msg
113+
#!/bin/sh
114+
. "\$(dirname "\$0")/_/husky.sh"
115+
116+
npx --no -- commitlint --edit "\${1}"
117+
EEE
118+
```
119+
120+
Make hook executable
121+
122+
```sh
123+
chmod a+x .husky/commit-msg
119124
```
120125

121126
Check the [husky documentation](https://typicode.github.io/husky/#/?id=manual) on how you can automatically have Git hooks enabled after install for different `yarn` versions.

0 commit comments

Comments
 (0)