-
Notifications
You must be signed in to change notification settings - Fork 2
/
codeclimate
executable file
·43 lines (38 loc) · 1.12 KB
/
codeclimate
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
#!/bin/bash -e
# Runs Code Climate on the current working directory.
usage() {
(
echo "usage: ${0##*/} [-h|--help] [-v]"
echo "Runs Code Climate on the current working directory."
echo
echo "options:"
(
echo " -h, --help@ show usage help"
echo " -v@ verbose, show docker command"
) | column -ts@
) >&2
exit 1
}
if echo "$*" | grep -Eq -- '--help\b|-h\b'; then
usage
fi
VERBOSE=0
while getopts "v" opt; do
case "$opt" in
v) VERBOSE=1 ;;
*) usage ;;
esac
done
shift $((OPTIND - 1))
# See: https://github.com/codeclimate/codeclimate#usage
[[ -n $1 ]] && CC_CMD="$*" || CC_CMD="help"
DOCKER_CMD="docker run"
DOCKER_CMD="$DOCKER_CMD --interactive --tty --rm"
DOCKER_CMD="$DOCKER_CMD --env CODECLIMATE_CODE=\"$PWD\""
DOCKER_CMD="$DOCKER_CMD --volume \"$PWD\":/code"
DOCKER_CMD="$DOCKER_CMD --volume /var/run/docker.sock:/var/run/docker.sock"
DOCKER_CMD="$DOCKER_CMD --volume /tmp/cc:/tmp/cc"
DOCKER_CMD="$DOCKER_CMD codeclimate/codeclimate"
DOCKER_CMD="$DOCKER_CMD $CC_CMD"
[[ $VERBOSE == "1" ]] && echo "$DOCKER_CMD"
eval "$DOCKER_CMD"