-
Notifications
You must be signed in to change notification settings - Fork 1
/
.rvmrc
76 lines (66 loc) · 1.69 KB
/
.rvmrc
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
current_directory=$(pwd) # Save the current directory
while [ ! -e ".rvmrc" ]; do
cd ..
done
light_green="\033[1;32m"
light_red="\033[1;32m"
disable="\033[0m"
activate_virtualenv() {
echo -en $light_green
echo -n "Activating virtualenv... "
source bin/activate
echo "Done."
echo -en $disable
}
check_requirements() {
echo -en $light_green
echo -n "Checking requirements... "
pip install --no-install --no-download -r "${directory}dev-requirements.txt" > /dev/null
return_code=$?
if [ $return_code == 1 ]; then
echo "[NEED UPDATE]"
else
echo "[OK]"
fi
echo -en $disable
return $return_code
}
install_requirements() {
echo -en $light_green
echo -n "Installing requirements... "
echo -e $disable
pip install -r "${directory}dev-requirements.txt"
echo -en $light_green
echo "Done."
echo -en $disable
}
if [ -f bin/activate ]; then
activate_virtualenv
else
echo -en $light_green
echo -n "Creating new virtual environment... "
if type -P virtualenv &> /dev/null; then
virtualenv . --no-site-packages > /dev/null
elif type -P virtualenv2 &> /dev/null; then
virtualenv2 . > /dev/null
else
echo -en $light_red
echo "Please install virtualenv"
echo -en $disable
return
fi
echo "Done."
echo -en $disable
activate_virtualenv
fi
# find django project directory
manage_file=$(ls */manage.py)
directory=${manage_file%manage.py}
check_requirements
if [ $? == 1 ]; then
install_requirements
fi
cd $current_directory # Go to initial destination directory
unset -f install_requirements
unset -f check_requirements
unset -f activate_virtualenv