【发布时间】:2022-11-09 11:49:02
【问题描述】:
I am using win10.
when clicking the blue button on the Github desktop to commit something.
error husky - pre-commit hook exited with code 1 (error) appears.
But if i type git commit -m "sth" in terminal, the pre-commit hook works fine
=============================
part of my package.json
"lint-staged": {
"*.{js,jsx,tsx,ts}": "eslint --cache --fix",
"*.{js,css,md,jsx,tsx,ts}": "prettier --write"
}
============================
.husky/pre-commit.sh
. "$(dirname "$0")/_/husky.sh"
npx lint-staged
============================
.husky/_/husky.sh
#!/bin/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
export readonly husky_skip_init=1
sh -e "$0" "$@"
exitCode="$?"
if [ $exitCode != 0 ]; then
echo "husky - $hook_name hook exited with code $exitCode (error)"
fi
exit $exitCode
fi
-
are you using gitbash terminal ?
-
Hi @Aron, any solutions? I have the same error
标签: pre-commit-hook github-desktop pre-commit husky