Skip to content

Commit 17eb466

Browse files
committed
fix: fix readme identation; fix escaping for marker; fix identation of option loop
1 parent c6065ae commit 17eb466

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -608,8 +608,13 @@ Unlike most other hooks, this hook triggers once if there are any changed files
608608
- --hook-config=--add-to-existing-file=true # Boolean. true or false
609609
- --hook-config=--create-file-if-not-exist=true # Boolean. true or false
610610
- --hook-config=--use-standard-markers=true # Boolean. Defaults to true (v1.93+), false (<v1.93). Set to true for compatibility with terraform-docs
611-
- --hook-config=--custom-marker-begin # String. Defaults to "<!-- BEGIN_TF_DOCS -->" (v1.93+), "<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->" (<v1.93). Set to use custom marker which helps you with using other formats like asciidoc
612-
- --hook-config=--custom-marker-end # String. Defaults to "<!-- END_TF_DOCS -->" (v1.93+), "<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->" (<v1.93). Set to use custom marker which helps you with using other formats like asciidoc
611+
# The following two options "--custom-marker-begin" and "--custom-marker-end" are ignored if "--use-standard-markers" is set to false
612+
- --hook-config=--custom-marker-begin # String. Defaults to "<!-- BEGIN_TF_DOCS -->" (v1.93+), "<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->" (<v1.93).
613+
# Set to use custom marker which helps you with using other formats like asciidoc.
614+
# For Asciidoc this could be "--hook-config=--custom-marker-begin=// BEGIN_TF_DOCS"
615+
- --hook-config=--custom-marker-end # String. Defaults to "<!-- END_TF_DOCS -->" (v1.93+), "<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->" (<v1.93).
616+
# Set to use custom marker which helps you with using other formats like asciidoc.
617+
# For Asciidoc this could be "--hook-config=--custom-marker-end=// END_TF_DOCS"
613618
```
614619

615620
4. If you want to use a terraform-docs config file, you must supply the path to the file, relative to the git repo root path:

hooks/terraform_docs.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ function replace_old_markers {
4242

4343
# Determine the appropriate sed command based on the operating system (GNU sed or BSD sed)
4444
sed --version &> /dev/null && SED_CMD=(sed -i) || SED_CMD=(sed -i '')
45-
"${SED_CMD[@]}" -e "s|^${old_insertion_marker_begin}$|${insertion_marker_begin}|" "$file"
46-
"${SED_CMD[@]}" -e "s|^${old_insertion_marker_end}$|${insertion_marker_end}|" "$file"
45+
"${SED_CMD[@]}" -e "s/^${old_insertion_marker_begin}$/${insertion_marker_begin//\//\\/}/" "$file"
46+
"${SED_CMD[@]}" -e "s/^${old_insertion_marker_end}$/${insertion_marker_begin//\//\\/}/" "$file"
4747
}
4848

4949
#######################################################################
@@ -115,11 +115,13 @@ function terraform_docs {
115115
common::colorify "yellow" "WARNING: --use-standard-markers is deprecated and will be removed in the future."
116116
common::colorify "yellow" " All needed changes already done by the hook, feel free to remove --use-standard-markers setting from your pre-commit config"
117117
;;
118-
--custom-marker-begin)
118+
--custom-marker-begin)
119119
insertion_marker_begin=$value
120+
common::colorify "yellow" "INFO: --custom-marker-begin is used and the marker is set to \"$value\"."
120121
;;
121-
--custom-marker-end)
122+
--custom-marker-end)
122123
insertion_marker_end=$value
124+
common::colorify "yellow" "INFO: --custom-marker-end is used and the marker is set to \"$value\"."
123125
;;
124126
esac
125127
done

0 commit comments

Comments
 (0)