Skip to content

Commit 6ff3572

Browse files
authored
fix(terraform_docs): Suppress "terraform command not found" error message in case binary does not exist (antonbabenko#693)
1 parent 2d7a2fb commit 6ff3572

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

hooks/terraform_docs.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ function terraform_docs_ {
4747
IFS=";" read -r -a configs <<< "$hook_config"
4848

4949
local hack_terraform_docs
50-
hack_terraform_docs=$(terraform version | sed -n 1p | grep -c 0.12) || true
50+
local hack_terraform_docs=0
51+
if [[ $(\command -V terraform 2> /dev/null) ]]; then
52+
hack_terraform_docs=$(terraform version | sed -n 1p | grep -c 0.12) || true
53+
fi
5154

5255
if [[ ! $(command -v terraform-docs) ]]; then
5356
echo "ERROR: terraform-docs is required by terraform_docs pre-commit hook but is not installed or in the system's PATH."

0 commit comments

Comments
 (0)