mirror of
https://github.com/tofuutils/pre-commit-opentofu.git
synced 2025-10-15 17:38:54 +02:00
fix: Improve tflint --init command execution (#361)
This commit is contained in:
parent
896cbff5ed
commit
d31cb69363
1 changed files with 14 additions and 7 deletions
|
|
@ -17,6 +17,20 @@ function main {
|
||||||
# shellcheck disable=SC2178 # It's the simplest syntax for that case
|
# shellcheck disable=SC2178 # It's the simplest syntax for that case
|
||||||
ARGS=${ARGS[*]/__GIT_WORKING_DIR__/$(pwd)\/}
|
ARGS=${ARGS[*]/__GIT_WORKING_DIR__/$(pwd)\/}
|
||||||
# shellcheck disable=SC2128 # It's the simplest syntax for that case
|
# shellcheck disable=SC2128 # It's the simplest syntax for that case
|
||||||
|
|
||||||
|
# Run `tflint --init` for check that plugins installed.
|
||||||
|
# It should run once on whole repo.
|
||||||
|
{
|
||||||
|
TFLINT_INIT=$(tflint --init 2>&1) 2> /dev/null &&
|
||||||
|
common::colorify "green" "Command 'tflint --init' successfully done:" &&
|
||||||
|
echo -e "${TFLINT_INIT}\n\n\n"
|
||||||
|
} || {
|
||||||
|
local exit_code=$?
|
||||||
|
common::colorify "red" "Command 'tflint --init' failed:"
|
||||||
|
echo "${TFLINT_INIT}"
|
||||||
|
return ${exit_code}
|
||||||
|
}
|
||||||
|
|
||||||
common::per_dir_hook "$ARGS" "$HOOK_ID" "${FILES[@]}"
|
common::per_dir_hook "$ARGS" "$HOOK_ID" "${FILES[@]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -34,13 +48,6 @@ function per_dir_hook_unique_part {
|
||||||
local -r args="$1"
|
local -r args="$1"
|
||||||
local -r dir_path="$2"
|
local -r dir_path="$2"
|
||||||
|
|
||||||
# shellcheck disable=SC2091,SC2068 # Suppress error output
|
|
||||||
TFLINT_INIT=$(tflint --init 2>&1) 2> /dev/null || {
|
|
||||||
local exit_code=$?
|
|
||||||
common:colorify "yellow" "tflint init:"
|
|
||||||
echo "${TFLINT_INIT}"
|
|
||||||
return ${exit_code}
|
|
||||||
}
|
|
||||||
# Print checked PATH **only** if TFLint have any messages
|
# Print checked PATH **only** if TFLint have any messages
|
||||||
# shellcheck disable=SC2091,SC2068 # Suppress error output
|
# shellcheck disable=SC2091,SC2068 # Suppress error output
|
||||||
$(tflint ${args[@]} 2>&1) 2> /dev/null || {
|
$(tflint ${args[@]} 2>&1) 2> /dev/null || {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue