-
Notifications
You must be signed in to change notification settings - Fork 0
/
bundler-exec
executable file
·97 lines (84 loc) · 1.33 KB
/
bundler-exec
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/bash
# Automatically run Ruby scripts with "bundle exec" (but only when appropriate).
# http://effectif.com/ruby/automating-bundle-exec
# Github: https://github.com/gma/bundler-exec
## Functions
bundler-installed()
{
which bundle > /dev/null 2>&1
}
within-bundled-project()
{
local dir="$PWD"
while [ "$dir" != "/" ]; do
if [ -f "$dir/Gemfile" ]; then
return 0
fi
dir="$(dirname $dir)"
done
return 1
}
run-with-bundler()
{
if bundler-installed && within-bundled-project; then
bundle exec "$@"
else
"$@"
fi
}
define-bundler-aliases()
{
# Allow zsh to iterate over list of words
[ -n "$ZSH_VERSION" ] && setopt localoptions shwordsplit
local command
for command in $BUNDLED_COMMANDS; do
if [[ $command != "bundle" && $command != "gem" ]]; then
alias $command="run-with-bundler $command"
fi
done
}
## Main program
BUNDLED_COMMANDS="${BUNDLED_COMMANDS:-
cap
capify
chef
chefspec
chef-apply
chef-client
chef-shell
chef-solo
cucumber
foodcritic
guard
haml
html2haml
jasmine
jekyll
kitchen
knife
middleman
pry
rackup
rake
rake2thor
rspec
ruby
sass
sass-convert
serve
shotgun
sidekiq
spec
spork
strainer
thin
thor
tilt
tt
turn
unicorn
unicorn_rails
wagon
}"
define-bundler-aliases
unset -f define-bundler-aliases