From 8a13a5031dcfdadc0e4e9d4955ed897a05e58736 Mon Sep 17 00:00:00 2001 From: Dylan Decrulle <81740200+ddecrulle@users.noreply.github.com> Date: Mon, 19 Sep 2022 16:04:25 +0200 Subject: [PATCH] build: move husky conf --- .husky/commit-msg | 2 +- .husky/husky.sh | 36 ++++++++++++++++++++++++++++++++++++ .husky/pre-commit | 2 +- 3 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 .husky/husky.sh diff --git a/.husky/commit-msg b/.husky/commit-msg index d71a03b..a4ea5d5 100755 --- a/.husky/commit-msg +++ b/.husky/commit-msg @@ -1,4 +1,4 @@ #!/bin/sh -. "$(dirname "$0")/_/husky.sh" +. "$(dirname "$0")/husky.sh" yarn commitlint --edit $1 diff --git a/.husky/husky.sh b/.husky/husky.sh new file mode 100644 index 0000000..cec959a --- /dev/null +++ b/.husky/husky.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env sh +if [ -z "$husky_skip_init" ]; then + debug () { + if [ "$HUSKY_DEBUG" = "1" ]; then + echo "husky (debug) - $1" + fi + } + + readonly hook_name="$(basename -- "$0")" + debug "starting $hook_name..." + + if [ "$HUSKY" = "0" ]; then + debug "HUSKY env variable is set to 0, skipping hook" + exit 0 + fi + + if [ -f ~/.huskyrc ]; then + debug "sourcing ~/.huskyrc" + . ~/.huskyrc + fi + + readonly husky_skip_init=1 + export husky_skip_init + sh -e "$0" "$@" + exitCode="$?" + + if [ $exitCode != 0 ]; then + echo "husky - $hook_name hook exited with code $exitCode (error)" + fi + + if [ $exitCode = 127 ]; then + echo "husky - command not found in PATH=$PATH" + fi + + exit $exitCode +fi diff --git a/.husky/pre-commit b/.husky/pre-commit index dc0378c..4af173f 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +1,4 @@ #!/bin/sh -. "$(dirname "$0")/_/husky.sh" +. "$(dirname "$0")/husky.sh" yarn lint-staged \ No newline at end of file