我为 git 创建了一个预提交脚本,当通过命令行运行时它工作正常。这是那个脚本:
#!/bin/sh
#
# Pre-commit hooks
echo "Running unit tests..."
# Lint stuff before commiting
grunt runtests
RESULT=$?
[ $RESULT -ne 0 ] && echo "Tests (or tasks) failed, aborting the commit" && exit 1
echo "All tests passed, commiting your changes" && exit 0
我希望预先提交也可以通过 GitHub 客户端应用程序工作,但我无法让它工作。预提交脚本已执行,但会引发错误。这是它在客户端警报窗口中返回的全文:
Running unit tests...
.git/hooks/pre-commit: line 7: grunt: command not found
Tests (or tasks) failed, aborting the commit
(1)
由于某种原因,它无法找到咕噜声。我再次重新安装了 grunt cli 并使用了全局“-g”标志,但这没有任何区别。有什么想法可以让客户找到咕噜声吗?