Skip to content

Commit

Permalink
build: add husky pre-commit & commit-msg hooks (#181)
Browse files Browse the repository at this point in the history
* build: add husky pre-commit & commit-msg hooks

This change makes the following tasks run on each commit, at the following sequence:

- `husky:pre-commit` - runs the Grunt `test` task, including lint and test
- `husky:commit-msg` - checks whether the commit message follows https://conventionalcommits.org
  • Loading branch information
stbodurov authored Jul 11, 2022
1 parent b6777ec commit 65fdd91
Show file tree
Hide file tree
Showing 6 changed files with 1,002 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
. "$(dirname "$0")/common.sh"

npm run husky:commit-msg
8 changes: 8 additions & 0 deletions .husky/common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
command_exists () {
command -v "$1" >/dev/null 2>&1
}

# Windows 10, Git Bash and Yarn workaround
if command_exists winpty && test -t 1; then
exec < /dev/tty
fi
5 changes: 5 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
. "$(dirname "$0")/common.sh"

npm run husky:pre-commit
1 change: 1 addition & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = { extends: ['@commitlint/config-conventional'] };
Loading

0 comments on commit 65fdd91

Please sign in to comment.