Sha256: 14003756c1c32c235ce89ad3b3b52b95a3deadc84eac89f158020d77a07eb650

Contents?: true

Size: 1.39 KB

Versions: 7

Compression:

Stored size: 1.39 KB

Contents

#!/bin/bash
if [[ "${@}" == "--init" ]]; then
  # Add next? top of Gemfile
  cat <<-STRING > Gemfile.tmp
def next?
  File.basename(__FILE__) == "Gemfile.next"
end
STRING
  cat Gemfile >> Gemfile.tmp
  mv Gemfile.tmp Gemfile

  ln -s Gemfile Gemfile.next
  echo <<-MESSAGE
Created Gemfile.next (a symlink to your Gemfile). Your Gemfile has been modified to support dual-booting!

There's just one more step: modify your Gemfile to use a newer version of Rails using the \`next?\` helper method.

For example, here's how to go from 5.2.3 to 6.0:

if next?
  gem "rails", "6.0.0"
else
  gem "rails", "5.2.3"
end
MESSAGE
  exit $?
fi

if [[ "${@}" =~ ^bundle ]]; then
  BUNDLE_GEMFILE=Gemfile.next BUNDLE_CACHE_PATH=vendor/cache.next $@
else
  BUNDLE_GEMFILE=Gemfile.next BUNDLE_CACHE_PATH=vendor/cache.next bundle exec $@
fi

COMMAND_EXIT=$?

GEM_NOT_FOUND=7 # https://github.com/bundler/bundler/blob/master/lib/bundler/errors.rb#L35
EXECUTABLE_NOT_FOUND=127 # https://github.com/bundler/bundler/blob/master/lib/bundler/cli/exec.rb#L62
if [[ $COMMAND_EXIT -eq $GEM_NOT_FOUND || $COMMAND_EXIT -eq $EXECUTABLE_NOT_FOUND ]]; then
  BLUE='\033[0;34m'
  UNDERLINE_WHITE='\033[37m'
  NO_COLOR='\033[0m'

  echo -e "${BLUE}Having trouble running commands with ${UNDERLINE_WHITE}bin/next${BLUE}?"
  echo -e "Try running ${UNDERLINE_WHITE}bin/next bundle install${BLUE}, then try your command again.${NO_COLOR}"
fi

exit $COMMAND_EXIT

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
next_rails-1.0.4 exe/next.sh
next_rails-1.0.3 exe/next.sh
next_rails-1.0.2 exe/next.sh
ten_years_rails-1.0.2 exe/next.sh
ten_years_rails-1.0.1 exe/next.sh
next_rails-1.0.1 exe/next.sh
next_rails-1.0.0 exe/next.sh