Skip to content

Commit

Permalink
feat: When a config file is given, do not specify formatter on cli (t…
Browse files Browse the repository at this point in the history
…erraform_docs) (#386)
  • Loading branch information
acodeninja committed May 25, 2022
1 parent 5e92703 commit 962054b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions hooks/terraform_docs.sh
Expand Up @@ -135,6 +135,11 @@ function terraform_docs {
esac
done

#
# Override formatter if no config file set
#
[[ "$args" != *"--config="* ]] && local tf_docs_formatter="md"

local dir_path
for dir_path in $(echo "${paths[*]}" | tr ' ' '\n' | sort -u); do
dir_path="${dir_path//__REPLACED__SPACE__/ }"
Expand Down Expand Up @@ -181,7 +186,7 @@ function terraform_docs {

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

awk -f "$terraform_docs_awk_file" ./*.tf > "$tmp_file_docs_tf"
# shellcheck disable=SC2086
terraform-docs md $args "$tmp_file_docs_tf" > "$tmp_file"
terraform-docs $tf_docs_formatter $args "$tmp_file_docs_tf" > "$tmp_file"
rm -f "$tmp_file_docs_tf"
fi

Expand Down

0 comments on commit 962054b

Please sign in to comment.