Skip to content

Commit 962054b

Browse files
authored
feat: When a config file is given, do not specify formatter on cli (terraform_docs) (antonbabenko#386)
1 parent 5e92703 commit 962054b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

hooks/terraform_docs.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@ function terraform_docs {
135135
esac
136136
done
137137

138+
#
139+
# Override formatter if no config file set
140+
#
141+
[[ "$args" != *"--config="* ]] && local tf_docs_formatter="md"
142+
138143
local dir_path
139144
for dir_path in $(echo "${paths[*]}" | tr ' ' '\n' | sort -u); do
140145
dir_path="${dir_path//__REPLACED__SPACE__/ }"
@@ -181,7 +186,7 @@ function terraform_docs {
181186

182187
if [[ "$terraform_docs_awk_file" == "0" ]]; then
183188
# shellcheck disable=SC2086
184-
terraform-docs md $args ./ > "$tmp_file"
189+
terraform-docs $tf_docs_formatter $args ./ > "$tmp_file"
185190
else
186191
# Can't append extension for mktemp, so renaming instead
187192
local tmp_file_docs
@@ -192,7 +197,7 @@ function terraform_docs {
192197

193198
awk -f "$terraform_docs_awk_file" ./*.tf > "$tmp_file_docs_tf"
194199
# shellcheck disable=SC2086
195-
terraform-docs md $args "$tmp_file_docs_tf" > "$tmp_file"
200+
terraform-docs $tf_docs_formatter $args "$tmp_file_docs_tf" > "$tmp_file"
196201
rm -f "$tmp_file_docs_tf"
197202
fi
198203

0 commit comments

Comments
 (0)