-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
gemfile-exec
executable file
·56 lines (48 loc) · 1.03 KB
/
gemfile-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
#!/bin/bash
# Examples:
#
# gemfile-exec -c "rake spec" gemfiles/rails4.2.gemfile
# gemfile-exec -c "rake spec" gemfiles/*.gemfile
function usage() {
echo "Usage: gemfile-exec -c <command> gemfile ..."
echo " gemfile-exec gemfile ..."
}
command=rake
while getopts ":c:h" opt; do
case $opt in
c)
command=$OPTARG
;;
h)
usage
exit 0
;;
\?)
echo "Invalid option: -$OPTARG" >&2
usage
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
# getopts is done; shift all processed options away
shift $((OPTIND-1))
if [[ $# -eq 0 ]] ; then
usage
exit 1
fi
GREEN='\033[0;32m'
NC='\033[0m' # No Color
for gemfile in "$@"
do
echo
echo -e "${GREEN}BUNDLE_GEMFILE=$gemfile bundle exec ${command}${NC}"
echo -e "${GREEN}----------------------------------------------------------------------${NC}"
echo
export BUNDLE_GEMFILE="$gemfile"
bundle check || bundle install --path vendor
bundle exec ${command}
done