From ce02cd137e59d4f0924d382aa56a9266c2d6fea1 Mon Sep 17 00:00:00 2001 From: Maksym Vlasov Date: Thu, 30 Sep 2021 17:28:11 +0300 Subject: [PATCH] feat: Add PATH outputs when TFLint found any problem (#234) --- terraform_tflint.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/terraform_tflint.sh b/terraform_tflint.sh index 670e860..6da3b93 100755 --- a/terraform_tflint.sh +++ b/terraform_tflint.sh @@ -63,7 +63,18 @@ tflint_() { path_uniq="${path_uniq//__REPLACED__SPACE__/ }" pushd "$path_uniq" > /dev/null - tflint "${ARGS[@]}" + TFLINT_MSG=$( + tflint "${ARGS[@]}" 2>&1 || + echo >&2 -e "\033[1;31m\nERROR in ./$path_uniq/:\033[0m" && + tflint "${ARGS[@]}" # Print TFLint error with PATH + ) + + # Print checked PATH if TFLint have any messages + if [ ! -z "$TFLINT_MSG" ]; then + echo -e "\n./$path_uniq/:" + echo "$TFLINT_MSG" + fi + popd > /dev/null done }