Skip to content

Commit 8125f9c

Browse files
🤖 config(husky): Configure commit-msg hook.
These changes were automatically generated by a transform whose code can be found at: - https://github.com/make-github-pseudonymous-again/rejuvenate/blob/9b50c2a1d7e9ab7b4bc9c9ff88892e98c5f62244/src/transforms/husky:hook-configure-commit-msg.js Please contact the author of the transform if you believe there was an error.
1 parent 075bc97 commit 8125f9c

File tree

4 files changed

+504
-15
lines changed

4 files changed

+504
-15
lines changed

.commitlintrc.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
extends: ['@js-library']
3+
};

.husky/commit-msg

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
function ask () {
5+
6+
# This is a general-purpose function to ask Yes/No questions in Bash, either
7+
# with or without a default answer. It keeps repeating the question until it
8+
# gets a valid answer.
9+
10+
# http://djm.me/ask
11+
12+
if [ "${2:-}" = "Y" ]; then
13+
prompt="Y/n"
14+
default=Y
15+
elif [ "${2:-}" = "N" ]; then
16+
prompt="y/N"
17+
default=N
18+
else
19+
prompt="y/n"
20+
default=
21+
fi
22+
23+
while true; do
24+
25+
# Ask the question (not using "read -p" as it uses stderr not stdout)
26+
echo -n "$1 [$prompt] "
27+
28+
# Read the answer (use /dev/tty in case stdin is redirected from somewhere else)
29+
read REPLY </dev/tty
30+
31+
# Default?
32+
if [ -z "$REPLY" ]; then
33+
REPLY=$default
34+
fi
35+
36+
# Check if the reply is valid
37+
case "$REPLY" in
38+
Y*|y*) return 0 ;;
39+
N*|n*) return 1 ;;
40+
esac
41+
42+
done
43+
44+
}
45+
46+
while ! npm run commit-msg -- "$1" ; do
47+
if [ -t 1 ] && ask 'There was an error. Do you wish to amend your commit message?' Y ; then
48+
${GIT_EDITOR:-$EDITOR} "$1" < /dev/tty
49+
else
50+
exit 1
51+
fi
52+
done

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"build": "babel --delete-dir-on-start --env-name production src -d lib",
3131
"build-docs": "esdoc",
3232
"build-gh-pages": "npm run build-docs",
33+
"commit-msg": "commitlint --edit",
3334
"cover": "c8 --all --src src --reporter=lcov npm test",
3435
"dev": "npm run lint -- --fix && npm run cover -- -- -st --fail-fast",
3536
"install-hooks": "husky install",
@@ -53,13 +54,15 @@
5354
"@babel/core": "7.19.6",
5455
"@babel/preset-env": "7.19.4",
5556
"@babel/register": "7.18.9",
57+
"@commitlint/cli": "17.2.0",
5658
"@iterable-iterator/consume": "^1.0.1",
5759
"@iterable-iterator/iter": "^1.0.1",
5860
"@iterable-iterator/list": "^1.0.1",
5961
"@iterable-iterator/map": "^1.0.1",
6062
"@iterable-iterator/range": "^2.1.0",
6163
"@iterable-iterator/slice": "^1.0.2",
6264
"@iterable-iterator/sorted": "^1.0.0",
65+
"@js-library/commitlint-config": "0.0.4",
6366
"@randomized/random": "^4.1.0",
6467
"@total-order/primitive": "^1.0.1",
6568
"ava": "3.15.0",

0 commit comments

Comments
 (0)