oh-my-fish/plugins/bundler/bundler.load

33 lines
832 B
Fish
Raw Normal View History

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