Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxymVlasov committed Sep 9, 2024
1 parent a12f76f commit c0b1f38
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions hooks/terraform_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -264,17 +264,13 @@ function terraform_docs {
#? TF 0.12+ and terraform-docs 0.12.0+

#
# If `--add-to-existing-file=true` set, check is in file exist "hook markers",
# and if not - append "hook markers" to the end of file.
# If `--add-to-existing-file=false` (default behavior), check is in file exist "hook markers",
# and if not skip execution to avoid addition of terraform-docs section -
# terraform-docs in 'inject' mode adds markers by default if they not present
#
if $add_to_existing; then
if ! $add_to_existing; then
HAVE_MARKER=$(grep -o "$insertion_marker_begin" "$output_file" || exit 0)

if [ ! "$HAVE_MARKER" ]; then
# terraform-docs in 'inject; mode adds markers by default if they not present.
# So, we need need just skip execution to skip addition of terraform-docs section
continue
fi
[[ ! $HAVE_MARKER ]] && continue
fi
# shellcheck disable=SC2086
terraform-docs --output-mode="$output_mode" --output-file="$output_file" $tf_docs_formatter $args ./ > /dev/null
Expand All @@ -285,6 +281,10 @@ function terraform_docs {
#? but I portably just drop this section in next release of the hook,
#? as there no sense to support hacks for tool versions which was released more than 3 years ago

#
# If `--add-to-existing-file=true` set, check is in file exist "hook markers",
# and if not - append "hook markers" to the end of file.
#
if $add_to_existing; then
HAVE_MARKER=$(grep -o "$insertion_marker_begin" "$output_file" || exit 0)

Expand Down

0 comments on commit c0b1f38

Please sign in to comment.