diff options
author | Vijay A <avijayr@protonmail.com> | 2021-05-16 12:57:50 +0530 |
---|---|---|
committer | Vijay Raghavan Aravamudhan <vraravam@users.noreply.github.com> | 2021-05-16 12:58:45 +0530 |
commit | 47b30902244e9d9de969050aed6526f14f73694d (patch) | |
tree | e9b7ea9a158189338619a13e7fea601a26c1347e | |
parent | Fixing incorrect example in TweetDeck. (diff) | |
download | ferdium-recipes-47b30902244e9d9de969050aed6526f14f73694d.tar.gz ferdium-recipes-47b30902244e9d9de969050aed6526f14f73694d.tar.zst ferdium-recipes-47b30902244e9d9de969050aed6526f14f73694d.zip |
Adding husky pre-commit hook
-rw-r--r-- | .husky/_/husky.sh | 30 | ||||
-rwxr-xr-x | .husky/pre-commit | 4 | ||||
-rw-r--r-- | package.json | 5 |
3 files changed, 34 insertions, 5 deletions
diff --git a/.husky/_/husky.sh b/.husky/_/husky.sh new file mode 100644 index 0000000..ca2720e --- /dev/null +++ b/.husky/_/husky.sh | |||
@@ -0,0 +1,30 @@ | |||
1 | #!/bin/sh | ||
2 | if [ -z "$husky_skip_init" ]; then | ||
3 | debug () { | ||
4 | [ "$HUSKY_DEBUG" = "1" ] && echo "husky (debug) - $1" | ||
5 | } | ||
6 | |||
7 | readonly hook_name="$(basename "$0")" | ||
8 | debug "starting $hook_name..." | ||
9 | |||
10 | if [ "$HUSKY" = "0" ]; then | ||
11 | debug "HUSKY env variable is set to 0, skipping hook" | ||
12 | exit 0 | ||
13 | fi | ||
14 | |||
15 | if [ -f ~/.huskyrc ]; then | ||
16 | debug "sourcing ~/.huskyrc" | ||
17 | . ~/.huskyrc | ||
18 | fi | ||
19 | |||
20 | export readonly husky_skip_init=1 | ||
21 | sh -e "$0" "$@" | ||
22 | exitCode="$?" | ||
23 | |||
24 | if [ $exitCode != 0 ]; then | ||
25 | echo "husky - $hook_name hook exited with code $exitCode (error)" | ||
26 | exit $exitCode | ||
27 | fi | ||
28 | |||
29 | exit 0 | ||
30 | fi | ||
diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 0000000..1ecae40 --- /dev/null +++ b/.husky/pre-commit | |||
@@ -0,0 +1,4 @@ | |||
1 | #!/bin/sh | ||
2 | . "$(dirname "$0")/_/husky.sh" | ||
3 | |||
4 | npm run lint && npm run reformat-files && npm run package | ||
diff --git a/package.json b/package.json index ff973c1..12ef1f8 100644 --- a/package.json +++ b/package.json | |||
@@ -40,10 +40,5 @@ | |||
40 | "imagemin-cli": "^6.0.0", | 40 | "imagemin-cli": "^6.0.0", |
41 | "prettier": "^2.3.0", | 41 | "prettier": "^2.3.0", |
42 | "simple-git": "^2.39.0" | 42 | "simple-git": "^2.39.0" |
43 | }, | ||
44 | "husky": { | ||
45 | "hooks": { | ||
46 | "pre-commit": "npm run lint && npm run reformat-files && npm run package" | ||
47 | } | ||
48 | } | 43 | } |
49 | } | 44 | } |