|
1 | 1 | #! /usr/bin/env bash |
2 | 2 |
|
3 | | -# COLORS |
4 | | -OFF='\033[0m' |
5 | | -RED='\033[0;31m' |
6 | | -GREEN='\033[0;32m' |
7 | | -BLUE='\033[0;34m' |
8 | | -PURPLE='\033[0;35m' |
| 3 | +set -e # prevent any kind of script failures |
9 | 4 |
|
10 | | -set -e # Prevent any kind of script failures |
| 5 | +source script/env "$@" |
11 | 6 |
|
12 | | -# if any of the following env vars are set, use them for the APP_ENV value |
13 | | -if [ -n "$APP_ENV" ]; then |
14 | | - export APP_ENV="$APP_ENV" |
15 | | -elif [ -n "$ENV" ]; then |
16 | | - export APP_ENV="$ENV" |
17 | | -elif [ -n "$ENVIRONMENT" ]; then |
18 | | - export APP_ENV="$ENVIRONMENT" |
19 | | -elif [ -n "$RAILS_ENV" ]; then |
20 | | - export APP_ENV="$RAILS_ENV" |
21 | | -elif [ -n "$RACK_ENV" ]; then |
22 | | - export APP_ENV="$RACK_ENV" |
23 | | -fi |
24 | | - |
25 | | -# set the working directory to the root of the project |
26 | | -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )" |
27 | | - |
28 | | -# set the ruby version to the one specified in the .ruby-version file |
29 | | -[ -z "$RBENV_VERSION" ] && export RBENV_VERSION=$(cat "$DIR/.ruby-version") |
30 | | - |
31 | | -# set the app environment to development if it's not set |
32 | | -[ -z "$APP_ENV" ] && export APP_ENV="development" |
33 | | - |
34 | | -# set the path to include the rbenv shims if they exist |
35 | | -[ -d "/usr/share/rbenv/shims" ] && export PATH=/usr/share/rbenv/shims:$PATH |
36 | | - |
37 | | -TRASHDIR=$(mktemp -d /tmp/bootstrap.XXXXXXXXXXXXXXXXX) |
38 | | -cleanup() { |
39 | | - rm -rf "$TRASHDIR" |
40 | | - # Remove empty directory |
41 | | - rmdir "$DIR/vendor/cache" 2>/dev/null || true |
42 | | -} |
43 | | -trap cleanup EXIT |
44 | | - |
45 | | -# Bootstrap gem dependencies. |
46 | | -if [ "$APP_ENV" == "production" ]; then |
47 | | - echo -e "💎 ${BLUE}Installing Gems for ${GREEN}production${BLUE}...${OFF}" |
48 | | - BUNDLE_WITHOUT=development bundle install --local |
49 | | - BUNDLE_WITHOUT=development bundle binstubs --all |
| 7 | +# bootstrap gem dependencies |
| 8 | +if [ "$BUNDLE_WITHOUT" == "" ]; then |
| 9 | + echo -e "${BLUE}Installing Gems for ${PURPLE}development${BLUE}...${OFF}" |
50 | 10 | else |
51 | | - echo -e "💎 ${BLUE}Installing Gems for ${PURPLE}development${BLUE}...${OFF}" |
52 | | - bundle install --local |
53 | | - bundle binstubs --all |
| 11 | + echo -e "${BLUE}Installing Gems for ${GREEN}production${BLUE}...${OFF}" |
54 | 12 | fi |
| 13 | + |
| 14 | +# what gets installed is set via the BUNDLE_WITHOUT env var in the script/env file |
| 15 | +bundle install --local |
| 16 | +bundle binstubs --all |
0 commit comments