format-code: halt on missing linter
From a CI perspective, we want to halt if any of the tools are missing
from the docker image, as a sanity check that we did not mess that up.
Add an option (--allow-missing) that will simply warn and continue if
any linters are missing, but halt by default.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I1e39fcf80512f86679a2352a5eb29155df08162f
diff --git a/scripts/format-code.sh b/scripts/format-code.sh
index d6e3a2d..64ffcb1 100755
--- a/scripts/format-code.sh
+++ b/scripts/format-code.sh
@@ -19,6 +19,7 @@
echo " --list-tools Display available linters and formatters"
echo " --no-diff Don't show final diff output"
echo " --disable <tool> Disable linter"
+ echo " --allow-missing Run even if linters are not all present"
echo " path Path to git repository (default to pwd)"
}
@@ -33,7 +34,7 @@
LINTERS_DISABLED=()
LINTERS_ENABLED=()
-eval set -- "$(getopt -o 'h' --long 'help,list-tools,no-diff,disable:' -n 'format-code.sh' -- "$@")"
+eval set -- "$(getopt -o 'h' --long 'help,list-tools,no-diff,disable:,allow-missing' -n 'format-code.sh' -- "$@")"
while true; do
case "$1" in
'-h'|'--help')
@@ -58,6 +59,11 @@
shift && shift
;;
+ '--allow-missing')
+ ALLOW_MISSING=yes
+ shift
+ ;;
+
'--')
shift
break
@@ -219,6 +225,9 @@
if [ ! -x "${EXE}" ]; then
if ! which "${EXE}" > /dev/null 2>&1 ; then
echo -e " ${YELLOW}${TITLE}:${NORMAL} cannot find ${EXE}"
+ if [ -z "$ALLOW_MISSING" ]; then
+ exit 1
+ fi
return
fi
fi