我们有多个团队。
前端和后端。所有前端开发人员都node
在计算机上,但后端开发人员没有。
Husky ( https://typicode.github.io/husky/#/ ) 安装 commit-Hooks。对于后端开发人员,我们收到错误消息Can't find Husky, skipping pre-commit hook
。(因为node
他们的电脑上没有)。
我不希望他们被迫安装节点,因为我们在 Docker-Container 内完成所有这些工作。
.git/hooks
看起来像这样:
if [ -f "$scriptPath" ]; then
# if [ -t 1 ]; then
# exec < /dev/tty
# fi
if [ -f ~/.huskyrc ]; then
debug "source ~/.huskyrc"
source ~/.huskyrc
fi
node_modules/run-node/run-node "$scriptPath" $hookName "$gitParams"
或者在以后的版本中:
#!/bin/sh
if [ -z "$husky_skip_init" ]; then
debug () {
[ "$HUSKY_DEBUG" = "1" ] && echo "husky (debug) - $1"
}
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)"
exit $exitCode
fi
exit 0
fi
我可以以某种方式将 husky 配置为启动脚本执行docker-compose run app ....
吗?我想在容器内运行实际的脚本,但我没有让 husky 本身在容器中执行。