2012-07-30 04:31:04 +08:00
|
|
|
# The following is based on https://github.com/gma/bundler-exec
|
|
|
|
|
|
|
|
## Functions
|
|
|
|
function _bundler-installed
|
2012-08-04 07:01:41 +08:00
|
|
|
which bundle >/dev/null ^&1
|
2012-07-30 04:31:04 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
function _within-bundled-project
|
|
|
|
set -l check_dir $PWD
|
|
|
|
while [ $check_dir != "/" ]
|
2012-11-03 21:28:33 +08:00
|
|
|
test -f "$check_dir/Gemfile"; and return
|
2012-07-30 04:31:04 +08:00
|
|
|
set check_dir (dirname $check_dir)
|
|
|
|
end
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
|
|
|
function _run-with-bundler
|
2012-11-03 21:28:33 +08:00
|
|
|
if begin; _bundler-installed; and _within-bundled-project; end
|
2012-07-30 04:31:04 +08:00
|
|
|
command bundle exec $argv
|
|
|
|
else
|
2012-11-03 21:28:33 +08:00
|
|
|
eval command $argv
|
2012-07-30 04:31:04 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
### Main program
|
2013-03-20 04:36:17 +08:00
|
|
|
set -l bundled_commands annotate cap capify cucumber foreman guard middleman nanoc rackup rainbows rake rspec ruby shotgun sidekiq spec spinach spork thin thor unicorn unicorn_rails
|
2012-07-30 04:31:04 +08:00
|
|
|
|
|
|
|
for cmd in $bundled_commands
|
|
|
|
if not contains $cmd bundle gem
|
2012-08-14 08:14:01 +08:00
|
|
|
eval "function $cmd; _run-with-bundler $cmd \$argv;end"
|
2012-07-30 04:31:04 +08:00
|
|
|
end
|
|
|
|
end
|