Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(terraform_docs): Always use GNU sed
Browse files Browse the repository at this point in the history
Ensure sed commands are compatible with MacOS and Linux/GNO version
cschroer committed Aug 29, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 99fceb8 commit de569e0
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -585,8 +585,8 @@ Unlike most other hooks, this hook triggers once if there are any changed files
To migrate everything to `terraform-docs` insertion markers, run in repo root:

```bash
grep -rl 'BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK' . | xargs sed -i 's/BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK/BEGIN_TF_DOCS/g'
grep -rl 'END OF PRE-COMMIT-TERRAFORM DOCS HOOK' . | xargs sed -i 's/END OF PRE-COMMIT-TERRAFORM DOCS HOOK/END_TF_DOCS/g'
grep -rl 'BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK' . | xargs sed -i'' 's/BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK/BEGIN_TF_DOCS/g'
grep -rl 'END OF PRE-COMMIT-TERRAFORM DOCS HOOK' . | xargs sed -i'' 's/END OF PRE-COMMIT-TERRAFORM DOCS HOOK/END_TF_DOCS/g'
```

```yaml
4 changes: 2 additions & 2 deletions hooks/terraform_docs.sh
Original file line number Diff line number Diff line change
@@ -40,8 +40,8 @@ function main {
function replace_old_markers {
local -r file=$1

sed -i "s/^${old_insertion_marker_begin}$/${insertion_marker_begin}/" "$file"
sed -i "s/^${old_insertion_marker_end}$/${insertion_marker_end}/" "$file"
sed -i'' "s/^${old_insertion_marker_begin}$/${insertion_marker_begin}/" "$file"
sed -i'' "s/^${old_insertion_marker_end}$/${insertion_marker_end}/" "$file"
}

#######################################################################

0 comments on commit de569e0

Please sign in to comment.