9e819435 |
# This plugin is based on https://github.com/gma/bundler-exec |
69d30a63 |
# modify the bundled_commands if needed |
9e819435 |
|
37fcd4af |
bundled_commands=(cap capify cucumber heroku rackup rails rake rspec ruby shotgun spec spork thin unicorn unicorn_rails) |
9e819435 |
## Functions
|
69d30a63 |
_bundler-installed() { |
a77e6fb0 |
which bundle > /dev/null 2>&1 |
9e819435 |
}
|
69d30a63 |
_within-bundled-project() { |
a77e6fb0 |
local check_dir=$PWD
while [ "$(dirname $check_dir)" != "/" ]; do
[ -f "$check_dir/Gemfile" ] && return
check_dir="$(dirname $check_dir)"
done
false |
9e819435 |
}
|
69d30a63 |
_run-with-bundler() { |
a77e6fb0 |
local command="$1"
shift
if _bundler-installed && _within-bundled-project; then
bundle exec $command "$@"
else
$command "$@"
fi |
9e819435 |
}
## Main program |
05883f38 |
for cmd in $bundled_commands; do |
a77e6fb0 |
alias $cmd="_run-with-bundler $cmd" |
9e819435 |
done |