Skip to content

Commit c70229c

Browse files
committed
add scripts/luals-check, not quite ready for CI
1 parent 8393f7c commit c70229c

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/luals-out/

scripts/luals-check

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/sh
2+
3+
# Performs a lua-language-server check on all files.
4+
# luals-out/check.json will be produced on any issues, returning 1.
5+
# Outputs only check.json to stdout, all other messages to stderr, to allow jq etc.
6+
7+
VER_LLS="3.7.3"
8+
9+
DIR_SRC="${PWD}"
10+
DIR_OUT="${DIR_SRC}/luals-out"
11+
DIR_LLS="/tmp/lls"
12+
13+
# clear output
14+
rm -rf "${DIR_OUT}"
15+
mkdir "${DIR_OUT}"
16+
17+
if [ ! -d "${DIR_LLS}" ]; then
18+
# download lua-language-server binaries
19+
mkdir -p "${DIR_LLS}"
20+
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}"
21+
fi
22+
23+
# execute from within the lua-language-server directory as it expects specific file locations
24+
OUT=$("${DIR_LLS}/bin/lua-language-server" --checklevel=Information --check "${DIR_SRC}" --logpath="${DIR_OUT}" --loglevel=error)
25+
RC=$?
26+
27+
echo "${OUT}" >&2
28+
29+
if [ $RC -ne 0 ]; then
30+
exit $RC
31+
fi
32+
33+
# any output is a fail
34+
case "${OUT}" in
35+
*Diagnosis\ complete*)
36+
if [ -f "${DIR_OUT}/check.json" ]; then
37+
cat "${DIR_OUT}/check.json"
38+
exit 1
39+
else
40+
exit 0
41+
fi
42+
;;
43+
*)
44+
exit 1
45+
;;
46+
esac
47+

0 commit comments

Comments
 (0)