-
Notifications
You must be signed in to change notification settings - Fork 16
/
carthage-developer-uncheckouts
executable file
·51 lines (40 loc) · 1.41 KB
/
carthage-developer-uncheckouts
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
#!/bin/bash
#
# This script reverses the effect of carthage-developer-checkouts.
#
# Usage:
# cd ProjectFolder && /path/to/carthage-developer-uncheckouts
mkdir -p "Carthage/Checkouts/"
project_dir=$PWD
parent_dir=$(dirname "$PWD")
sed -E 's/(github|git|binary) \"([^\"]+)\" \"([^\"]+)\"/\2 \3/g' Cartfile.resolved | while read line
do
read -a array <<< "$line"
# Handles:
# - ReactiveCocoa/ReactiveSwift > ReactiveSwift
# - https://github.com/Carthage/Carthage.git > Carthage
# - https://www.mapbox.com/ios-sdk/Mapbox-iOS-SDK.json > Mapbox-iOS-SDK
dependency=`basename ${array[0]} | awk -F'.' '{ print $1 }'`
dependency_dir="$parent_dir/$dependency"
checkout_dir="Carthage/Checkouts/$dependency"
echo "*** Reverting $dependency"
if [ -d "$dependency_dir/.git" -a -L "$checkout_dir" ]
then
if [ -L "$dependency_dir/Carthage/Build" ]
then
echo -e "\tRemoving symlink $dependency/Carthage/Build -> $project_dir/Carthage/Build"
rm -rf "$dependency_dir/Carthage/Build" || exit $?
fi
echo -e "\tRemoving symlink $checkout_dir -> $dependency_dir"
rm -rf "$checkout_dir" || exit $?
carthage checkout $dependency --no-use-binaries
else
echo -e "\tWarning: $dependency symlink not found, skipping."
fi
# Remove Build folder since it might be out of date now
if [ -L "Carthage/Build" ]
then
rm -rf "Carthage/Build"
fi
echo
done