-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsass
executable file
·121 lines (113 loc) · 2.74 KB
/
sass
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/bin/bash
# Help
help()
{
echo "Swift Assist tool version 1.0"
echo "Maintained by Jack Hamilton"
echo
echo "Syntax: sass -[h|c|r]|--[help|clean|reset_simulators]"
echo
echo "-h, --help: Displays the current help description."
echo
echo "-c, --clean: Cleans an xcode project in the current directory."
echo "Wipes derived data, clears gemfile.lock & podfile.lock, cleans"
echo "pods and cocoapods artifacts. "
echo
echo "-r, --reset_simulators: Erases all active simulators."
echo
}
clean()
{
local gitRoot=$(git rev-parse --show-toplevel)
cd "$gitRoot"
local hasBundler=$(has_bundler)
if [ "$hasBundler" = "1" ]; then
bundle exec pod cache clean --all
else
pod cache clean --all
fi
swift package purge-cache
swift package reset
swift package clean
rm -rf ../Pods/
rm -rf ../Podfile.lock
rm -rf "${HOME}/Library/Caches/CocoaPods"
while [ -d ~/Library/Developer/Xcode/DerivedData ]
do
rm -rf ~/Library/Developer/Xcode/DerivedData
if [ -d ~/Library/Developer/Xcode/DerivedData ]; then
printf "Could not acquire lock on derived data. Retrying."
for i in {1..5}
do
sleep 1
printf "."
done
printf "\n"
fi
done
SETUP_SCRIPT=scripts/install_dependencies.sh
if test -f "$SETUP_SCRIPT"; then
echo "Executing dependency setup script."
sh "$SETUP_SCRIPT"
fi
if [ "$hasBundler" = "1" ]; then
bundle exec pod install --repo-update
else
pod install --repo-update
fi
swift package resolve
swift package update
echo "Clean complete."
}
reset_simulators()
{
xcrun simctl shutdown all
killall "Simulator" 2> /dev/null
xcrun simctl erase all
echo "Simulators reset."
}
has_bundler()
{
if gem list --local | grep -q 'bundler'; then
echo 1
else
echo 0
fi
}
has_argument() {
[[ ("$1" == *=* && -n ${1#*=}) || ( ! -z "$2" && "$2" != -*) ]];
}
extract_argument() {
echo "${2:-${1#*=}}"
}
handle_options() {
while [ $# -gt 0 ]; do
case $1 in
-h | --help)
help
exit 0
;;
-c | --clean)
clean
exit 0
;;
-r | --reset_simulators)
reset_simulators
exit 0
;;
#-o | --option*) if ! has_argument $@; then fi
*)
echo "Invalid option: $1" >&2
echo
help
exit 1
;;
esac
shift
done
}
handle_options "$@"
if [ "$#" -ne 1 ]; then
help
exit 0
fi