Created
December 27, 2020 16:36
-
-
Save danielgomezrico/8c8fa1f0f553278f086397c2b73b204a to your computer and use it in GitHub Desktop.
Flutter - Check code format and fail if does not work, useful for CI flows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# Runs dartfmt from dart_style to check if all of the source files are well formatted | |
# Requires you to have dartfmt already in your path with 'pub global activate dart_style' | |
# | |
echo "-> Running 'flutter format' to check project dart style 🤓" | |
RESULT=$(flutter format -n lib/main.dart lib/src/ test/) | |
if [[ $? != 0 ]]; then | |
echo "----> Command failed." | |
elif [[ $RESULT ]]; then | |
echo "----> Some files are looking weird here 🤓:" | |
echo "$RESULT" | |
exit 1 | |
else | |
echo "----> All format is good ✅" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment