Skip to content

Commit

Permalink
fix lint script
Browse files Browse the repository at this point in the history
  • Loading branch information
jessesquires committed Jul 9, 2024
1 parent 7d22dcc commit 57788e8
Showing 1 changed file with 43 additions and 44 deletions.
87 changes: 43 additions & 44 deletions scripts/lint.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -9,67 +9,66 @@
#
# Runs SwiftLint and checks for installation of correct version.

set -e
export PATH="$PATH:/opt/homebrew/bin"

if [[ "${GITHUB_ACTIONS}" ]]; then
# ignore on GitHub Actions
exit 0
fi

set -e
export PATH="$PATH:/opt/homebrew/bin"
LINK="https://github.com/realm/SwiftLint"
INSTALL="brew install swiftlint"

if ! which swiftlint >/dev/null; then
echo "
Error: SwiftLint not installed!
Download: $LINK
Install: $INSTALL
"
exit 0
fi

PROJECT="Foil.xcodeproj"
SCHEME="Foil"

VERSION="0.55.1"

FOUND=$(swiftlint version)
LINK="https://github.com/realm/SwiftLint"
INSTALL="brew install swiftlint"

CONFIG="./.swiftlint.yml"

if which swiftlint >/dev/null; then
echo "Running swiftlint..."
echo "Running swiftlint..."
echo ""

# no arguments, just lint without fixing
if [[ $# -eq 0 ]]; then
swiftlint --config $CONFIG
echo ""
fi

# no arguments, just lint without fixing
if [[ $# -eq 0 ]]; then
swiftlint --config $CONFIG
for argval in "$@"
do
# run --fix
if [[ "$argval" == "fix" ]]; then
echo "Auto-correcting lint errors..."
echo ""
swiftlint --fix --progress --config $CONFIG && swiftlint --config $CONFIG
echo ""
# run analyze
elif [[ "$argval" == "analyze" ]]; then
LOG="xcodebuild.log"
echo "Running anaylze..."
echo ""
xcodebuild -scheme $SCHEME -project $PROJECT clean build-for-testing > $LOG
swiftlint analyze --fix --progress --format --strict --config $CONFIG --compiler-log-path $LOG
rm $LOG
echo ""
else
echo "Error: invalid arguments."
echo "Usage: $0 [fix] [analyze]"
echo ""
fi

for argval in "$@"
do
# run --fix
if [[ "$argval" == "fix" ]]; then
echo "Auto-correcting lint errors..."
echo ""
swiftlint --fix --progress --config $CONFIG && swiftlint --config $CONFIG
echo ""
# run analyze
elif [[ "$argval" == "analyze" ]]; then
LOG="xcodebuild.log"
echo "Running anaylze..."
echo ""
xcodebuild -scheme $SCHEME -project $PROJECT clean build-for-testing > $LOG
swiftlint analyze --fix --progress --format --strict --config $CONFIG --compiler-log-path $LOG
rm $LOG
echo ""
else
echo "Error: invalid arguments."
echo "Usage: $0 [fix] [analyze]"
echo ""
fi
done
else
echo "
Error: SwiftLint not installed!
Download: $LINK
Install: $INSTALL
"
exit 0
fi
done

if [ $FOUND != $VERSION ]; then
echo "
Expand Down

0 comments on commit 57788e8

Please sign in to comment.