Last active
August 29, 2015 14:20
-
-
Save adrianwebb/c60a59558e22d5b4d4ec to your computer and use it in GitHub Desktop.
Symbolic links Vagrant gems with current directory gems repositories for development.
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
#!/bin/bash | |
current_dir=`pwd` | |
gem_dir="$current_dir/gems" | |
gem_files=() | |
index=1 | |
echo "Gathering gem repositories from $gem_dir" | |
for file in "$gem_dir"/* | |
do | |
gem_files[$index]="$file" | |
index=$(($index+1)) | |
done | |
echo 'Switching Vagrant gems with development versions' | |
for vagrant_gem_file in "$HOME"/.vagrant.d/gems/gems/* | |
do | |
if [ -e "$vagrant_gem_file" -a "$vagrant_gem_file" != '.' -a "$vagrant_gem_file" != '..' ] | |
then | |
vagrant_gem_name=`basename "$vagrant_gem_file"` | |
for gem_file in "${gem_files[@]}" | |
do | |
gem_name=`basename "$gem_file"` | |
if [[ "$vagrant_gem_name" =~ ^$gem_name- ]] | |
then | |
echo "Switching gem $vagrant_gem_name with $gem_file" | |
rm -Rf "$vagrant_gem_file" | |
ln -s "$gem_file" "$vagrant_gem_file" | |
fi | |
done | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment