We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 52b486a commit c62e67fCopy full SHA for c62e67f
pre-commit-hook.sh
@@ -7,7 +7,16 @@
7
echo
8
echo -e "${GREEN} ###### RUNNING PRE-COMMIT HOOKS ###### ${NC}"
9
10
-find . -type f -name "*.sh" -execdir shfmt -w {} \;
+files=$(find . -type f -name "*.sh" -exec shfmt -l {} \;)
11
+if [ -n "$files" ]; then
12
+ echo "Error: The following shell files need formatting:"
13
+ echo "$files"
14
+ echo ""
15
+ echo "Running: find . -type f -name \"*.sh\" -exec shfmt -w {} \\;"
16
+ find . -type f -name "*.sh" -execdir shfmt -w {} \;
17
+ echo "git add the formatted files and commit again"
18
+ exit 1
19
+fi
20
21
# NOTE: `find -execdir` cannot be used because it does not propagate errors
22
# NOTE: I am passing the filename as a parameter to the bash subshell, see
0 commit comments