我们有多个团队。前端和后端。所有的前端开发都有node在计算机上,但没有后端开发。
哈士奇(https://typicode.github.io/husky/#/)安装提交钩子。对于后端开发程序,我们得到了错误消息Can't find Husky, skipping pre-commit hook。(因为计算机上没有node)。
我不想让他们被迫安装节点,因为我们在一个码头容器里面做所有的事情。
.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我可以将哈士奇配置为启动脚本执行docker-compose run app ....吗?我希望在容器中运行实际的脚本,但是我不会让哈士奇自己在容器中执行。
发布于 2021-06-14 21:17:58
如果我对你的理解是正确的,我已经分两步解决了这个问题:
共享来自主机的git
# at docker-compose.yaml
version: '3'
services:
app:
build:
...
volumes:
- /usr/bin/git:/usr/bin/git
# installing dependencies missing at guest (in my case, guest debian, host ubuntu)
- /lib/x86_64-linux-gnu/libpcre2-8.so.0:/lib/x86_64-linux-gnu/libpcre2-8.so.0和2.通过在容器中运行钩子命令,例如:
# at .husky/pre-commit
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
# instead of only npx lint-staged
docker exec great-app npx lint-staged https://stackoverflow.com/questions/67786756
复制相似问题