add scripts/luals-check, not quite ready for CI
This commit is contained in:
parent
8393f7cc0c
commit
c70229cad9
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/luals-out/
|
||||
47
scripts/luals-check
Executable file
47
scripts/luals-check
Executable file
@ -0,0 +1,47 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Performs a lua-language-server check on all files.
|
||||
# luals-out/check.json will be produced on any issues, returning 1.
|
||||
# Outputs only check.json to stdout, all other messages to stderr, to allow jq etc.
|
||||
|
||||
VER_LLS="3.7.3"
|
||||
|
||||
DIR_SRC="${PWD}"
|
||||
DIR_OUT="${DIR_SRC}/luals-out"
|
||||
DIR_LLS="/tmp/lls"
|
||||
|
||||
# clear output
|
||||
rm -rf "${DIR_OUT}"
|
||||
mkdir "${DIR_OUT}"
|
||||
|
||||
if [ ! -d "${DIR_LLS}" ]; then
|
||||
# download lua-language-server binaries
|
||||
mkdir -p "${DIR_LLS}"
|
||||
curl -L "https://github.com/LuaLS/lua-language-server/releases/download/${VER_LLS}/lua-language-server-${VER_LLS}-linux-x64.tar.gz" | tar zx --directory "${DIR_LLS}"
|
||||
fi
|
||||
|
||||
# execute from within the lua-language-server directory as it expects specific file locations
|
||||
OUT=$("${DIR_LLS}/bin/lua-language-server" --checklevel=Information --check "${DIR_SRC}" --logpath="${DIR_OUT}" --loglevel=error)
|
||||
RC=$?
|
||||
|
||||
echo "${OUT}" >&2
|
||||
|
||||
if [ $RC -ne 0 ]; then
|
||||
exit $RC
|
||||
fi
|
||||
|
||||
# any output is a fail
|
||||
case "${OUT}" in
|
||||
*Diagnosis\ complete*)
|
||||
if [ -f "${DIR_OUT}/check.json" ]; then
|
||||
cat "${DIR_OUT}/check.json"
|
||||
exit 1
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
Loading…
Reference in New Issue
Block a user