From 35d5fa42c6102fa037a6446a970661c6cc7f0d57 Mon Sep 17 00:00:00 2001 From: Eric L Frederich Date: Tue, 30 Jun 2020 14:25:50 -0400 Subject: [PATCH] Honor excludes; don't run against entire directories (closes #121) --- terraform_fmt.sh | 29 ++--------------------------- 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/terraform_fmt.sh b/terraform_fmt.sh index d280574d1..7e05f2d8f 100755 --- a/terraform_fmt.sh +++ b/terraform_fmt.sh @@ -1,34 +1,9 @@ #!/usr/bin/env bash set -e -declare -a paths -declare -a tfvars_files - -index=0 - for file_with_path in "$@"; do file_with_path="${file_with_path// /__REPLACED__SPACE__}" - - paths[index]=$(dirname "$file_with_path") - - if [[ "$file_with_path" == *".tfvars" ]]; then - tfvars_files+=("$file_with_path") - fi - - let "index+=1" -done - -for path_uniq in $(echo "${paths[*]}" | tr ' ' '\n' | sort -u); do - path_uniq="${path_uniq//__REPLACED__SPACE__/ }" - - pushd "$path_uniq" > /dev/null - terraform fmt + pushd $(dirname "$file_with_path") + terraform fmt $(basename "$file_with_path") popd > /dev/null done - -# terraform.tfvars are excluded by `terraform fmt` -for tfvars_file in "${tfvars_files[@]}"; do - tfvars_file="${tfvars_file//__REPLACED__SPACE__/ }" - - terraform fmt "$tfvars_file" -done