-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathlint.zsh
executable file
·84 lines (70 loc) · 1.78 KB
/
lint.zsh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/zsh
# Created by Jesse Squires
# https://www.jessesquires.com
#
# Copyright © 2020-present Jesse Squires
#
# SwiftLint: https://github.com/realm/SwiftLint/releases/latest
#
# 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
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="ReactiveCollectionsKit.xcodeproj"
SCHEME="ReactiveCollectionsKit"
VERSION="0.57.0"
FOUND=$(swiftlint version)
CONFIG="./.swiftlint.yml"
echo "Running swiftlint..."
echo ""
# no arguments, just lint without fixing
if [[ $# -eq 0 ]]; then
swiftlint --config $CONFIG
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
if [ $FOUND != $VERSION ]; then
echo "
Warning: incorrect SwiftLint installed! Please upgrade.
Expected: $VERSION
Found: $FOUND
Download: $LINK
Install: $INSTALL
"
fi
exit 0