|
3 | 3 | [ -n "$GO_DEBUG" ] && set -x
|
4 | 4 | set -e
|
5 | 5 |
|
6 |
| -project_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" |
| 6 | +project_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
7 | 7 |
|
8 | 8 | verbose="no"
|
9 |
| -skip_checks="no" |
10 | 9 | offline="no"
|
| 10 | +skip_checks="no" |
11 | 11 |
|
12 | 12 | missing_dependency="no"
|
13 | 13 |
|
14 | 14 | [ -n "$GO_DEBUG" ] && verbose="yes"
|
15 | 15 | [ -n "$GO_SKIP_CHECKS" ] && skip_checks="yes"
|
16 | 16 | [ -n "$GO_OFFLINE" ] && offline="yes"
|
17 | 17 |
|
| 18 | +function loose_version() { |
| 19 | + local version="$1" |
| 20 | + |
| 21 | + IFS="." read -r -a version_parts <<<"$version" |
| 22 | + |
| 23 | + echo "${version_parts[0]}.${version_parts[1]}" |
| 24 | +} |
18 | 25 |
|
19 |
| -if [[ "$skip_checks" = "no" ]]; then |
20 |
| - echo "Checking for system dependencies." |
21 |
| - ruby_version="$(cat "$project_dir"/.ruby-version)" |
22 |
| - if ! type ruby >/dev/null 2>&1 || ! ruby -v | grep -q "$ruby_version"; then |
23 |
| - echo "This codebase requires Ruby $ruby_version." |
24 |
| - missing_dependency="yes" |
25 |
| - fi |
| 26 | +ruby_full_version="$(cat "$project_dir"/.ruby-version)" |
| 27 | +ruby_loose_version="$(loose_version "$ruby_full_version")" |
26 | 28 |
|
27 |
| - if [[ "$missing_dependency" = "yes" ]]; then |
28 |
| - echo "Please install missing dependencies to continue." |
29 |
| - exit 1 |
30 |
| - fi |
| 29 | +if [[ "$skip_checks" == "no" ]]; then |
| 30 | +echo "Checking for system dependencies." |
| 31 | + if ! type ruby >/dev/null 2>&1 || ! ruby -v | grep -q "$ruby_loose_version"; then |
| 32 | + echo "This codebase requires Ruby $ruby_loose_version." |
| 33 | + missing_dependency="yes" |
| 34 | + fi |
31 | 35 |
|
32 |
| - echo "All system dependencies present. Continuing." |
| 36 | + if ! type bundler >/dev/null 2>&1; then |
| 37 | + echo "This codebase requires Bundler." |
| 38 | + missing_dependency="yes" |
| 39 | + fi |
| 40 | + |
| 41 | + if [[ "$missing_dependency" = "yes" ]]; then |
| 42 | + echo "Please install missing dependencies to continue." |
| 43 | + exit 1 |
| 44 | + fi |
| 45 | + |
| 46 | + echo "All system dependencies present. Continuing." |
33 | 47 | fi
|
34 | 48 |
|
35 |
| -if [[ "$offline" = "no" ]]; then |
36 |
| - echo "Installing bundler." |
37 |
| - if [[ "$verbose" = "yes" ]]; then |
38 |
| - gem install --no-document bundler |
39 |
| - else |
40 |
| - gem install --no-document bundler > /dev/null |
41 |
| - fi |
42 |
| - |
43 |
| - echo "Installing ruby dependencies." |
44 |
| - if [[ "$verbose" = "yes" ]]; then |
45 |
| - bundle install |
46 |
| - else |
47 |
| - bundle install > /dev/null |
48 |
| - fi |
| 49 | +if [[ "$offline" == "no" ]]; then |
| 50 | + echo "Installing bundler." |
| 51 | + if [[ "$verbose" == "yes" ]]; then |
| 52 | + gem install --no-document bundler |
| 53 | + else |
| 54 | + gem install --no-document bundler >/dev/null |
| 55 | + fi |
| 56 | + |
| 57 | + echo "Installing ruby dependencies." |
| 58 | + if [[ "$verbose" == "yes" ]]; then |
| 59 | + bundle install |
| 60 | + else |
| 61 | + bundle install >/dev/null |
| 62 | + fi |
49 | 63 | fi
|
50 | 64 |
|
51 | 65 | echo "Starting rake."
|
52 |
| -if [[ "$verbose" = "yes" ]]; then |
53 |
| - time bundle exec rake --verbose "$@" |
| 66 | +if [[ "$verbose" == "yes" ]]; then |
| 67 | + time bundle exec rake --verbose "$@" |
54 | 68 | else
|
55 |
| - time bundle exec rake "$@" |
| 69 | + time bundle exec rake "$@" |
56 | 70 | fi
|
0 commit comments