Skip to content

Commit 1ece787

Browse files
committed
Push pre-commit
1 parent af49738 commit 1ece787

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

git_hooks/pre-commit

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/sh
2+
3+
result=$(dart format .)
4+
exitCode=$? # If the exitCode is zero, then command executed successfully.
5+
6+
if [ $exitCode -ne 0 ]; then
7+
echo "$result"
8+
echo "Dart format found issues, please fix them."
9+
exit 1
10+
fi
11+
echo "Finished running dart format command."
12+
13+
################################################################
14+
15+
result=$(dart analyze .)
16+
exitCode=$? # If the exitCode is zero, then command executed successfully.
17+
18+
if [ $exitCode -ne 0 ]; then
19+
echo "$result"
20+
fi
21+
echo "Finished running dart analyze command."
22+
23+
################################################################
24+
25+
# Run `dart dry --apply` to auto-fix basic issues.
26+
result=$(dart fix --apply)
27+
exitCode=$?
28+
29+
# Adding the files updated by `dart fix` command to git.
30+
git add .
31+
32+
echo "$result"
33+
34+
if [ $exitCode -ne 0 ]; then
35+
echo "dart fix command failed to execute."
36+
exit 1
37+
fi
38+
echo "Finished running dart fix command."

0 commit comments

Comments
 (0)