Allow to have spaces in directories (#11)

This commit is contained in:
Anton Babenko 2018-04-21 11:22:47 +02:00 committed by GitHub
commit 41d4951aff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 2 deletions

View file

@ -7,6 +7,8 @@ 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
@ -17,6 +19,8 @@ for file_with_path in "$@"; do
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
popd > /dev/null
@ -24,5 +28,7 @@ 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