From 3920d09706ca3a880d41d9e8d4fe53b971d3c748 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Tue, 28 Dec 2021 12:45:07 +0100 Subject: make: implement check-format in POSIX shell The docker image used for the CI does not contain bash. --- Makefile | 7 ++----- tools/check-format | 8 ++++++++ 2 files changed, 10 insertions(+), 5 deletions(-) create mode 100755 tools/check-format diff --git a/Makefile b/Makefile index cdf9647..7d505d4 100644 --- a/Makefile +++ b/Makefile @@ -4,19 +4,16 @@ LUA_FILES := $(shell find -name "*.lua" -not -path "./json.lua") TEST_FILES := $(shell find -name "*_test.lua") -# bash's process substitution is used for check-format -SHELL := /bin/bash - check: check-luacheck check-format check-luacheck: luacheck --globals=vis -- $(LUA_FILES) check-format: - for lf in $(LUA_FILES); do diff $$lf <(lua-format $$lf) >/dev/null; done + for lf in $(LUA_FILES); do tools/check-format "$${lf}"; done format: lua-format -i $(LUA_FILES) test: - for tf in $(TEST_FILES); do $$tf; done + for tf in $(TEST_FILES); do "$$tf"; done 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} -- cgit v1.2.3