Skip to content

Commit c797395

Browse files
committed
Rename tf commands and use tofu if found in the path
1 parent 23bd117 commit c797395

File tree

4 files changed

+27
-18
lines changed

4 files changed

+27
-18
lines changed

.pre-commit-hooks.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@
66
files: secrets.yml
77
types: [text]
88

9-
- id: terraform-fmt
10-
name: Check Terraform Format
9+
- id: tf-fmt
10+
name: Check TF Format
1111
description: This hook checks Terraform is formatteed correctly
12-
entry: bin/terraform-fmt.sh
12+
entry: bin/tf-fmt.sh
1313
language: script
1414
files: \.(tf)$
1515
types: [terraform]
1616

17-
- id: terraform-lint
18-
name: Check Terraform Lint
17+
- id: tf-lint
18+
name: Check TF Lint
1919
description: This hook checks Terraform lint
20-
entry: bin/terraform-lint.sh
20+
entry: bin/tf-lint.sh
2121
language: script
2222
files: \.(tf)$
2323
types: [terraform]

bin/terraform-fmt.sh

Lines changed: 0 additions & 12 deletions
This file was deleted.

bin/tf-fmt.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
3+
# LICENSE: The MIT License Copyright (c) 2023,2025 Volt Grid Pty Ltd t/a Panubo
4+
5+
# Runs Tofu or Terraform Format
6+
7+
set -e
8+
9+
if command -v tofu &> /dev/null; then
10+
TF_CMD='tofu'
11+
elif command -v terraform &> /dev/null; then
12+
TF_CMD='terraform'
13+
else
14+
echo "Error: Neither 'tofu' nor 'terraform' found in PATH." >&2
15+
exit 1
16+
fi
17+
18+
echo "Running pre-commit checks..."
19+
for FILE in "${@}"; do
20+
${TF_CMD} fmt "${FILE}"
21+
done
File renamed without changes.

0 commit comments

Comments
 (0)