In a project, we use Husky but when I try to add a commit with git add . and git commit -m "test", I receive below error
.husky/pre-commit: 2: .: Can't open .husky/_/husky.sh
How can i fix this problem ?
My operating system is Windows but I use Ubuntu on this project
I have a pre-commit file and it is as below
Also the codes for husky.sh is below
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
for this problem, I have come up with a solution as below. In my IDE, line endings use CRLF by default. So I changed it to LF from the bottom right corner of the IDE and it worked