heavyai-charting/scripts/check-formatting.sh
Matt Torok 4ab4641e95
[FE-8955] Format codebase + add formatting checker to test suite (#374)
* Run `npm run format` on entire codebase

* Add script to check formatting and make it part of the test suite

The script just runs `prettier`, but gives helpful headers and footers, since people seem perpetually confused about the test output when there's a formatting error. (To their credit, `prettier`'s output is less than helpful here.)
2019-08-06 15:29:13 -07:00

18 lines
546 B
Bash
Executable File

#!/usr/bin/env bash
# This script basically just runs `prettier`, but it adds a header and footer so that people aren't
# confused why their CI builds failed, since prettier's output is less-than-helpful.
echo -e "=====> Checking code formatting\n"
prettier --list-different '{src,test}/**/*.js'
PRETTIER_RES=$?
if [[ $PRETTIER_RES -ne 0 ]]; then
echo -e "\n!!! FATAL ERROR: The above files have formatting problems. Run \`npm run format\` to fix.\n\n"
else
echo -e "---> No code formatting problems found\n\n"
fi
exit $PRETTIER_RES