Created
June 10, 2012 15:28
-
-
Save mschuerig/2906200 to your computer and use it in GitHub Desktop.
Switch Gemfile.lock when rvm use'ing another ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Place this file at ~/.rvm/hooks/after_use_switch_gemfiles | |
# and make it executable. | |
# | |
# This version copies Ruby-specific Gemfile.lock.x to Gemfile.lock. | |
if [ -e "Gemfile" ]; then | |
. "${rvm_path}/scripts/functions/hooks/jruby" | |
unset current_platform gemfile_platform | |
if [[ "${rvm_ruby_string}" =~ "jruby" ]]; then | |
current_platform="jruby" | |
else | |
current_platform="mri" | |
fi | |
if [ -e "Gemfile.lock" ]; then | |
case $(sed -n '/^PLATFORMS/,/^$/ p' "Gemfile.lock" | sed '1d; /^$/d; s/\s*//') in | |
java) | |
gemfile_platform="jruby" | |
;; | |
ruby) | |
gemfile_platform="mri" | |
;; | |
esac | |
fi | |
if [ -n "$gemfile_platform" -a -e "Gemfile.lock" ]; then | |
/bin/cp -au "Gemfile.lock" "Gemfile.lock.${gemfile_platform}" | |
fi | |
if [ -n "$current_platform" -a -e "Gemfile.lock${current_platform}" ]; then | |
/bin/cp -au "Gemfile.lock.${current_platform}" "Gemfile.lock" | |
fi | |
unset current_platform gemfile_platform | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment