summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile14
-rwxr-xr-xtools/check-format8
2 files changed, 22 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..816596e
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,14 @@
+.PHONY: check format check-luacheck check-format
+
+LUA_FILES := $(shell find -name "*.lua")
+
+check: check-luacheck check-format
+
+check-luacheck:
+ luacheck --globals=vis -- $(LUA_FILES)
+
+check-format:
+ set -e; for lf in $(LUA_FILES); do tools/check-format "$${lf}"; done
+
+format:
+ lua-format -i $(LUA_FILES)
diff --git a/tools/check-format b/tools/check-format
new file mode 100755
index 0000000..392d023
--- /dev/null
+++ b/tools/check-format
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+LUA_FILE=$1
+lua-format "${LUA_FILE}" > "${LUA_FILE}.fmt"
+diff "${LUA_FILE}" "${LUA_FILE}.fmt"
+RET=$?
+rm "${LUA_FILE}.fmt"
+exit ${RET}