diff --git a/hooks/terragrunt-hcl-fmt.sh b/hooks/terragrunt-hcl-fmt.sh index 82b8af9c..59514031 100755 --- a/hooks/terragrunt-hcl-fmt.sh +++ b/hooks/terragrunt-hcl-fmt.sh @@ -10,6 +10,7 @@ export PATH=$PATH:/usr/local/bin check_terragrunt_version() { local minimum_supported_version="0.77.22" local current_version + local version_output if ! command -v terragrunt >/dev/null 2>&1; then echo "Warning: terragrunt command not found. Proceeding anyway..." >&2 @@ -17,7 +18,13 @@ check_terragrunt_version() { return 0 fi - if ! current_version=$(terragrunt --version 2>/dev/null | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1); then + version_output=$(terragrunt --version 2>/dev/null) + + if [[ "$version_output" == *"latest"* ]]; then + return 0 + fi + + if ! current_version=$(echo "$version_output" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1); then echo "Warning: Could not determine terragrunt version. Proceeding anyway..." >&2 return 0