forked from FunTimeCoding/jenkins-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun-style-check.sh
executable file
·47 lines (35 loc) · 1.25 KB
/
run-style-check.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
#!/bin/sh -e
if [ "$(command -v shellcheck || true)" = "" ]; then
echo "Command not found: shellcheck"
exit 1
fi
CONTINUOUS_INTEGRATION_MODE=false
if [ "${1}" = --ci-mode ]; then
shift
mkdir -p build/log
CONTINUOUS_INTEGRATION_MODE=true
fi
# 12345678901234567890123456789012345678901234567890123456789012345678901234567890
echo "================================================================================"
echo
echo "Run ShellCheck."
OPERATING_SYSTEM=$(uname)
if [ "${OPERATING_SYSTEM}" = Darwin ]; then
FIND=gfind
else
FIND=find
fi
if [ "${CONTINUOUS_INTEGRATION_MODE}" = true ]; then
# shellcheck disable=SC2016
${FIND} . -name '*.sh' -regextype posix-extended ! -regex '^.*/(build|.git)/.*$' -exec sh -c 'shellcheck ${1} || true' '_' '{}' \; | tee build/log/shellcheck.txt
else
# shellcheck disable=SC2016
${FIND} . -name '*.sh' -regextype posix-extended ! -regex '^.*/(build|.git)/.*$' -exec sh -c 'shellcheck ${1} || true' '_' '{}' \;
fi
echo
echo "================================================================================"
echo
echo "Search for empty files."
find . -empty -and -not -path '*/.git/*' -ls
echo
echo "================================================================================"