-
Notifications
You must be signed in to change notification settings - Fork 1
/
go
executable file
·73 lines (55 loc) · 1.6 KB
/
go
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
#!/usr/bin/env bash
[ -n "$GO_DEBUG" ] && set -x
set -e
project_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
verbose="no"
offline="no"
skip_checks="no"
missing_dependency="no"
[ -n "$GO_DEBUG" ] && verbose="yes"
[ -n "$GO_SKIP_CHECKS" ] && skip_checks="yes"
[ -n "$GO_OFFLINE" ] && offline="yes"
function loose_version() {
local version="$1"
IFS="." read -r -a version_parts <<<"$version"
echo "${version_parts[0]}.${version_parts[1]}"
}
function read_version() {
local tool="$1"
local tool_versions
tool_versions="$(cat "$project_dir"/.tool-versions)"
echo "$tool_versions" | grep "$tool" | cut -d ' ' -f 2
}
ruby_full_version="$(read_version "ruby")"
ruby_loose_version="$(loose_version "$ruby_full_version")"
if [[ "$skip_checks" == "no" ]]; then
echo "Checking for system dependencies."
if ! type ruby >/dev/null 2>&1 || ! ruby -v | grep -q "$ruby_loose_version"; then
echo "This codebase requires Ruby $ruby_loose_version."
missing_dependency="yes"
fi
if [[ "$missing_dependency" = "yes" ]]; then
echo "Please install missing dependencies to continue."
exit 1
fi
echo "All system dependencies present. Continuing."
fi
if [[ "$CI" = "yes" ]]; then
bundle config --global silence_root_warning true
fi
if [[ "$offline" = "no" ]]; then
if ! bundle check > /dev/null 2>&1; then
echo "Installing ruby dependencies."
if [[ "$verbose" = "yes" ]]; then
bundle install
else
bundle install >/dev/null
fi
fi
fi
echo "Starting rake."
if [[ "$verbose" = "yes" ]]; then
time bundle exec rake --verbose "$@"
else
time bundle exec rake "$@"
fi