mas/script/format
2021-04-28 19:14:18 -07:00

35 lines
835 B
Bash
Executable file

#!/bin/bash -e
#
# script/format
# mas
#
# Linting checks for development and CI.
#
# Automatically formats and fixes style violations using various tools.
# Additionally runs `lint` to report any remaining style violations.
#
# Please keep in sync with script/lint.
#
echo "==> 🚨 Formatting mas"
for LINTER in shfmt swift-format swiftformat swiftlint; do
if [[ ! -x "$(command -v ${LINTER})" ]]; then
echo "error: ${LINTER} is not installed. Run 'script/bootstrap' or 'brew install ${LINTER}'."
exit 1
fi
done
echo
echo "--> 🕊️ Swift"
for SOURCE in Package.swift Sources Tests; do
swiftformat ${SOURCE}
swift-format format --in-place --configuration .swift-format --recursive ${SOURCE}
swiftlint lint --fix --strict ${SOURCE}
done
echo
echo "--> 📜 Bash"
shfmt -i 2 -l -w contrib/ script/
script/lint