Skip to content

Commit 4e1d5fb

Browse files
committed
update bootstrap script
1 parent cd3cac8 commit 4e1d5fb

1 file changed

Lines changed: 49 additions & 9 deletions

File tree

script/bootstrap

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,54 @@
1-
#!/bin/bash
1+
#! /usr/bin/env bash
22

3-
set -e
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'
9+
10+
set -e # Prevent any kind of script failures
11+
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
426
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )"
5-
cd "$DIR"
627

7-
export PATH=/usr/share/rbenv/shims:$PATH
8-
export RBENV_VERSION="$(cat .ruby-version)"
9-
rm -rf "${DIR}/.bundle"
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
1036

11-
# Using Deprecated Flags to avoid pulling from upstream
12-
bundle install --local
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
1344

14-
bundle binstubs rake rspec-core rubocop
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
50+
else
51+
echo -e "💎 ${BLUE}Installing Gems for ${PURPLE}development${BLUE}...${OFF}"
52+
bundle install --local
53+
bundle binstubs --all
54+
fi

0 commit comments

Comments
 (0)