-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbundler-exec.sh
executable file
·79 lines (71 loc) · 1.04 KB
/
bundler-exec.sh
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
#!/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 [ "$(dirname $dir)" != "/" ]; do
[ -f "$dir/Gemfile" ] && return
dir="$(dirname $dir)"
done
false
}
run-with-bundler()
{
if bundler-installed && within-bundled-project; then
bundle exec "$@"
else
"$@"
fi
}
## Main program
BUNDLED_COMMANDS="${BUNDLED_COMMANDS:-
cap
capify
chefspec
chef-apply
chef-client
chef-shell
chef-solo
cucumber
foodcritic
foreman
guard
haml
html2haml
jasmine
kitchen
knife
middleman
pry
rackup
rake
rake2thor
rspec
ruby
sass
sass-convert
serve
shotgun
spec
spork
strainer
thin
thor
tilt
tt
turn
unicorn
unicorn_rails
}"
for CMD in $BUNDLED_COMMANDS; do
if [[ $CMD != "bundle" && $CMD != "gem" ]]; then
alias $CMD="run-with-bundler $CMD"
fi
done