/
prepare.sh
executable file
·90 lines (72 loc) · 1.29 KB
/
prepare.sh
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
#!/bin/bash
# === FUNCTIONS ===
# --- print and exit functions ---
function print_info()
{
echo " -- $1"
}
function print_warn()
{
echo " ** $1"
}
function force_exit()
{
echo " !! $2, exiting..."
show_help
exit $1
}
function safe_exit()
{
echo " -- Safely exiting..."
cleanup
show_launch_help
exit 0
}
function show_help()
{
cat << EOF
usage: $0
This script prepares project.
EOF
}
function show_launch_help()
{
echo ""
print_info "If you see no error or notifications up, then"
print_info "you can launch your project with command"
print_info "coffee app.coffee"
echo ""
}
# --- helper functions ---
function cleanup()
{
print_info "Cleaning up"
}
function create_dir()
{
if [ ! -d $1 ]; then
print_info "Creating directory: $1"
mkdir -p $1 # if $1 doesn't exist, create it
if [ $? -ne 0 ]; then
force_exit 1 "Could not create $1"
fi
fi
}
echo ""
print_info "Preparing project"
# === LOGIC ===
function init_submodules()
{
print_info "Initializing git submodules"
#git submodule update --init --recursive
git submodule init && git submodule update
}
function install_npm_dependencies()
{
print_info "Installing npm dependencies (locally)"
npm install --local
echo " -- "
}
init_submodules
install_npm_dependencies
safe_exit