-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathironsetup
executable file
·99 lines (77 loc) · 1.84 KB
/
ironsetup
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
#!/usr/bin/env bash
#
# Globals
#
IRON_PACKAGES_SRC="$HOME/src/iron/packages"
BRANCH="next"
IRON_PACKAGES=(core dynamic-template layout controller component url location middleware-stack router)
#
# Help and usage info.
#
display_help() {
cat <<-EOF
Setup and develop on iron packages.
Usage: setup [options]
Options:
--help Display help
--branch Set all iron packages to use a particular branch
--use Put the iron packages in Meteor's package lookup
EOF
exit 0
}
function use() {
echo "Setting PACKAGE_DIRS environment variable"
export PACKAGE_DIRS="$IRON_PACKAGES_SRC:$PACKAGE_DIRS"
}
#
# Setup
#
function setup() {
# create package directory
echo "Making sure iron package directory exists at $IRON_PACKAGES_SRC"
mkdir -p "$IRON_PACKAGES_SRC"
# clone all packages
local saved_pwd="$PWD"
cd "$IRON_PACKAGES_SRC"
for package in "${IRON_PACKAGES[@]}"
do
if [ ! -d "iron:$package" ]; then
echo "Cloning $package into iron:$package"
git clone https://github.com/eventedmind/iron-"$package".git iron:"$package"
else
echo "iron:$package already exists so doing nothing."
fi
done
checkout;
cd $saved_pwd;
}
function checkout() {
local saved_pwd="$PWD"
cd "$IRON_PACKAGES_SRC"
for package in "${IRON_PACKAGES[@]}"
do
echo "Checking out $BRANCH branch of iron:$package"
(cd "iron:$package" && git checkout "$BRANCH")
done
echo ""
echo "All iron packages should now be on the \"$BRANCH\" branch"
echo ""
cd $saved_pwd;
}
#
# Handle arguments.
#
if [ $# -eq 0 ]; then
setup
else
while [ $# -ne 0 ]; do
case $1 in
-h|--help|help) display_help ;;
--branch) BRANCH="$2"; shift ;;
--use) use ;;
*) display_help ;;
esac
shift
done
setup $1
fi