-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathdocker-coala.sh
executable file
·57 lines (45 loc) · 1.72 KB
/
docker-coala.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
#!/bin/bash
# coala Docker Image entrypoint script
# This script is run if there's no command being passed
PREFIX="\033[1;34m>> \033[0m"
ADDITIONAL_BEARS_DIR="/additional_bears"
function msg {
echo -e "$PREFIX$@"
}
# Declare this is a dumb terminal
# because by default docker doesn't create a pseudo-tty
export TERM="dumb"
# Check if the working directory is changed from the default
if [[ "$(pwd)" == "/" ]]; then
msg "It looks like you forgot to define a working directory\n"
msg "To properly use this Docker Image,"
msg "You have to bind your project to this container and" \
"set the working directory to the container-side bind, like this:"
msg "docker run coala/base --volume=\$(pwd):/work --workdir=/work [command]"
msg "You can also define an additional bear directory, like this:"
msg "docker run coala/base --volume=\$(pwd):/work" \
"--volume\$(pwd)/mybears:$ADDITIONAL_BEARS_DIR --workdir=/work [command]"
exit 1
fi
# Check if .gitignore exists
# See https://github.com/coala/coala-quickstart/issues/49
if [[ ! -f .gitignore ]]; then
msg "It looks like there's no .gitignore file," \
"Creating a blank one ..."
touch .gitignore
fi
# Check if .coafile exists
if [[ ! -f .coafile ]]; then
msg ".coafile doesn't exist," \
"Running coala-quickstart to create one ..."
coala-quickstart --non-interactive
fi
# Check if additional bears folder exists
if [[ -d $ADDITIONAL_BEARS_DIR ]]; then
msg "Additional bears directory present," \
"Adding it to additional bear directories"
COALA_ARGS="$COALA_ARGS --bear-dirs $ADDITIONAL_BEARS_DIR"
fi
# Run coala non-interactively
msg "Running coala non-interactively ..."
exec coala $COALA_ARGS --non-interactive