-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.sh
More file actions
executable file
·65 lines (58 loc) · 1.28 KB
/
entrypoint.sh
File metadata and controls
executable file
·65 lines (58 loc) · 1.28 KB
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
#!/usr/bin/env bash
set -eu;
##
## build command
##
COMMAND="shellcheck"
if [[ -n "${PLUGIN_FORMAT:-}" ]]; then
COMMAND+=" --format=$PLUGIN_FORMAT"
fi
if [[ -n "${PLUGIN_COLOR:-}" ]]; then
COMMAND+=" --color=$PLUGIN_COLOR"
else
COMMAND+=" --color=always"
fi
if [[ -n "${PLUGIN_SHELL:-}" ]]; then
COMMAND+=" --shell=$PLUGIN_SHELL"
fi
if [[ -n "${PLUGIN_SEVERITY:-}" ]]; then
COMMAND+=" --severity=$PLUGIN_SEVERITY"
fi
if [[ -n "${PLUGIN_INCLUDE:-}" ]]; then
COMMAND+=" --include=$PLUGIN_INCLUDE"
fi
if [[ -n "${PLUGIN_EXCLUDE:-}" ]]; then
COMMAND+=" --exclude=$PLUGIN_EXCLUDE"
fi
# custom args, e.g. docker run --rm --volume=$(pwd):$(pwd) --workdir=$(pwd) --env=CI=test kokuwaio/shellcheck --format=json
if [[ -n "${1:-}" ]]; then
COMMAND+=" $*"
fi
##
## collect files (https://www.shellcheck.net/wiki/Recursiveness)
##
FILES=$(find "$(pwd)" -type f \
\( -name '*.sh' \
-o -name '*.ksh' \
-o -name '*.bash' \
-o -name '*.bashrc' \
-o -name '*.bash_profile' \
-o -name '*.bash_login' \
-o -name '*.bash_logout' \) \
-not -path '*/node_modules/*')
if [[ ! "$FILES" ]]; then
echo "No files found!"
exit 1
fi
for FILE in ${FILES}; do
COMMAND+=" \n $FILE"
done
##
## execute command
##
if [[ -n "${CI:-}" ]]; then
echo -e "$COMMAND"
else
echo -e "${COMMAND//\\n/}"
fi
eval "${COMMAND//\\n/}"