File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11#! /usr/bin/env bash
22set -e
33
4- declare -a paths
5- declare -a tfvars_files
6-
7- index=0
8-
94for file_with_path in " $@ " ; do
105 file_with_path=" ${file_with_path// / __REPLACED__SPACE__} "
11-
12- paths[index]=$( dirname " $file_with_path " )
13-
14- if [[ " $file_with_path " == * " .tfvars" ]]; then
15- tfvars_files+=(" $file_with_path " )
16- fi
17-
18- let " index+=1"
19- done
20-
21- for path_uniq in $( echo " ${paths[*]} " | tr ' ' ' \n' | sort -u) ; do
22- path_uniq=" ${path_uniq// __REPLACED__SPACE__/ } "
23-
24- pushd " $path_uniq " > /dev/null
25- terraform fmt
6+ pushd $( dirname " $file_with_path " ) > /dev/null
7+ terraform fmt $( basename " $file_with_path " )
268 popd > /dev/null
279done
28-
29- # terraform.tfvars are excluded by `terraform fmt`
30- for tfvars_file in " ${tfvars_files[@]} " ; do
31- tfvars_file=" ${tfvars_file// __REPLACED__SPACE__/ } "
32-
33- terraform fmt " $tfvars_file "
34- done
You can’t perform that action at this time.
0 commit comments