Skip to content

Commit 944a2e5

Browse files
authored
feat: Removed coreutils (realpath) from dependencies for MacOS (antonbabenko#368)
1 parent 4874cfe commit 944a2e5

14 files changed

+15
-17
lines changed

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,8 @@ Set `-e PRE_COMMIT_COLOR=never` to disable the color output in `pre-commit`.
114114

115115
<details><summary><b>MacOS</b></summary><br>
116116

117-
[`coreutils`](https://formulae.brew.sh/formula/coreutils) is required for hooks on MacOS (due to use of `realpath`).
118-
119117
```bash
120-
brew install pre-commit terraform-docs tflint tfsec coreutils checkov terrascan infracost tfupdate jq
118+
brew install pre-commit terraform-docs tflint tfsec checkov terrascan infracost tfupdate jq
121119
```
122120

123121
</details>

hooks/_common.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ function common::is_hook_run_on_whole_repo {
6969
shift 1
7070
local -a -r files=("$@")
7171
# get directory containing `.pre-commit-hooks.yaml` file
72-
local -r root_config_dir="$(dirname "$(dirname "$(realpath "${BASH_SOURCE[0]}")")")"
72+
local -r root_config_dir="$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)")"
7373
# get included and excluded files from .pre-commit-hooks.yaml file
7474
local -r hook_config_block=$(sed -n "/^- id: $hook_id$/,/^$/p" "$root_config_dir/.pre-commit-hooks.yaml")
7575
local -r included_files=$(awk '$1 == "files:" {print $2; exit}' <<< "$hook_config_block")

hooks/infracost_breakdown.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ set -eo pipefail
66
# shellcheck disable=SC2034 # Unused var.
77
readonly HOOK_ID='infracost_breakdown'
88
# shellcheck disable=SC2155 # No way to assign to readonly variable in separate lines
9-
readonly SCRIPT_DIR="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
9+
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
1010
# shellcheck source=_common.sh
1111
. "$SCRIPT_DIR/_common.sh"
1212

hooks/terraform_checkov.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ set -eo pipefail
66
# shellcheck disable=SC2034 # Unused var.
77
readonly HOOK_ID='terraform_checkov'
88
# shellcheck disable=SC2155 # No way to assign to readonly variable in separate lines
9-
readonly SCRIPT_DIR="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
9+
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
1010
# shellcheck source=_common.sh
1111
. "$SCRIPT_DIR/_common.sh"
1212

hooks/terraform_docs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ set -eo pipefail
66
# shellcheck disable=SC2034 # Unused var.
77
readonly HOOK_ID='terraform_docs'
88
# shellcheck disable=SC2155 # No way to assign to readonly variable in separate lines
9-
readonly SCRIPT_DIR="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
9+
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
1010
# shellcheck source=_common.sh
1111
. "$SCRIPT_DIR/_common.sh"
1212

hooks/terraform_fmt.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ set -eo pipefail
66
# shellcheck disable=SC2034 # Unused var.
77
readonly HOOK_ID='terraform_fmt'
88
# shellcheck disable=SC2155 # No way to assign to readonly variable in separate lines
9-
readonly SCRIPT_DIR="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
9+
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
1010
# shellcheck source=_common.sh
1111
. "$SCRIPT_DIR/_common.sh"
1212

hooks/terraform_providers_lock.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ set -eo pipefail
66
# hook ID, see `- id` for details in .pre-commit-hooks.yaml file
77
readonly HOOK_ID='terraform_providers_lock'
88
# shellcheck disable=SC2155 # No way to assign to readonly variable in separate lines
9-
readonly SCRIPT_DIR="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
9+
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
1010
# shellcheck source=_common.sh
1111
. "$SCRIPT_DIR/_common.sh"
1212

hooks/terraform_tflint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ set -eo pipefail
66
# hook ID, see `- id` for details in .pre-commit-hooks.yaml file
77
readonly HOOK_ID='terraform_tflint'
88
# shellcheck disable=SC2155 # No way to assign to readonly variable in separate lines
9-
readonly SCRIPT_DIR="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
9+
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
1010
# shellcheck source=_common.sh
1111
. "$SCRIPT_DIR/_common.sh"
1212

hooks/terraform_tfsec.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set -eo pipefail
55
# hook ID, see `- id` for details in .pre-commit-hooks.yaml file
66
readonly HOOK_ID='terraform_tfsec'
77
# shellcheck disable=SC2155 # No way to assign to readonly variable in separate lines
8-
readonly SCRIPT_DIR="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
8+
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
99
# shellcheck source=_common.sh
1010
. "$SCRIPT_DIR/_common.sh"
1111

hooks/terraform_validate.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ set -eo pipefail
66
# shellcheck disable=SC2034 # Unused var.
77
readonly HOOK_ID='terraform_validate'
88
# shellcheck disable=SC2155 # No way to assign to readonly variable in separate lines
9-
readonly SCRIPT_DIR="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
9+
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
1010
# shellcheck source=_common.sh
1111
. "$SCRIPT_DIR/_common.sh"
1212

@@ -110,7 +110,7 @@ function terraform_validate_ {
110110

111111
if [[ -n "$(find "$dir_path" -maxdepth 1 -name '*.tf' -print -quit)" ]]; then
112112

113-
pushd "$(realpath "$dir_path")" > /dev/null
113+
pushd "$(cd "$dir_path" && pwd -P)" > /dev/null
114114

115115
if [ ! -d .terraform ]; then
116116
set +e

0 commit comments

Comments
 (0)