From 6ff3572afb0a70c6fe4c6a0524d1f332a4f8fb6c Mon Sep 17 00:00:00 2001 From: Lucas Ponce Date: Thu, 1 Aug 2024 14:18:01 -0300 Subject: [PATCH] fix(`terraform_docs`): Suppress "terraform command not found" error message in case binary does not exist (#693) --- hooks/terraform_docs.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hooks/terraform_docs.sh b/hooks/terraform_docs.sh index 472d6487c..9fe0de440 100755 --- a/hooks/terraform_docs.sh +++ b/hooks/terraform_docs.sh @@ -47,7 +47,10 @@ function terraform_docs_ { IFS=";" read -r -a configs <<< "$hook_config" local hack_terraform_docs - hack_terraform_docs=$(terraform version | sed -n 1p | grep -c 0.12) || true + local hack_terraform_docs=0 + if [[ $(\command -V terraform 2> /dev/null) ]]; then + hack_terraform_docs=$(terraform version | sed -n 1p | grep -c 0.12) || true + fi if [[ ! $(command -v terraform-docs) ]]; then echo "ERROR: terraform-docs is required by terraform_docs pre-commit hook but is not installed or in the system's PATH."