diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 9d5b459..37221d7 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -2,7 +2,7 @@ name: pre-commit on: [push, pull_request, workflow_dispatch] jobs: - build: + check: runs-on: ubuntu-latest steps: @@ -12,11 +12,17 @@ jobs: - name: install luarocks run: sudo apt-get install -y luarocks + - name: add luarocks path + run: echo "$HOME/.luarocks/bin" >> $GITHUB_PATH + - name: luacheck install run: luarocks install --local luacheck - - name: add luacheck path - run: echo "$HOME/.luarocks/bin" >> $GITHUB_PATH + - name: install cargo + run: sudo apt-get install -y cargo + + - name: install stylua + run: cargo install stylua - name: Install pre-commit run: pip3 install pre-commit diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1b81d73..3d311a8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,7 +5,6 @@ repos: - id: fix-byte-order-marker - id: end-of-file-fixer - id: trailing-whitespace - - id: mixed-line-ending args: [ --fix=lf ] @@ -15,5 +14,12 @@ repos: name: luacheck language: system entry: luacheck - pass_filenames: false - args: [-q,.] + pass_filenames: true + types: [ file, lua ] + args: [ -q ] + - id: stylua + name: stylua + language: system + entry: stylua + pass_filenames: true + types: [ file, lua ] diff --git a/command.lua b/command.lua index 2519b34..8f4accf 100644 --- a/command.lua +++ b/command.lua @@ -38,7 +38,6 @@ minetest.register_chatcommand("run_in_book", { function minetest.chat_send_player(name2, message) if name == name2 then table.insert(received_messages, minetest.strip_colors(futil.strip_translation(message))) - else old_chat_send_player(name2, message) end @@ -53,14 +52,16 @@ minetest.register_chatcommand("run_in_book", { local text = table.concat(received_messages, "\n") local written_book = ItemStack("default:book_written") - written_book:get_meta():from_table({fields = { - title = param, - owner = name, - description = S("\"@1\" by @2", param, name), - text = text, - page = 1, - page_max = math.ceil((#text:gsub("[^\n]", "") + 1) / 14) - }}) + written_book:get_meta():from_table({ + fields = { + title = param, + owner = name, + description = S('"@1" by @2', param, name), + text = text, + page = 1, + page_max = math.ceil((#text:gsub("[^\n]", "") + 1) / 14), + }, + }) player:set_wielded_item(written_book) diff --git a/init.lua b/init.lua index 376ef0d..2b27bc8 100644 --- a/init.lua +++ b/init.lua @@ -3,29 +3,28 @@ local modpath = minetest.get_modpath(modname) local S = minetest.get_translator(modname) assert( - type(futil.version) == "number" and futil.version >= os.time({year = 2022, month = 10, day = 24}), + type(futil.version) == "number" and futil.version >= os.time({ year = 2022, month = 10, day = 24 }), "please update futil" ) book_runner = { author = "flux", license = "AGPL_v3", - version = os.time({year = 2022, month = 9, day = 30}), + version = os.time({ year = 2022, month = 9, day = 30 }), fork = "flux", modname = modname, modpath = modpath, S = S, - has = { - }, + has = {}, log = function(level, messagefmt, ...) return minetest.log(level, ("[%s] %s"):format(modname, messagefmt:format(...))) end, dofile = function(...) - return dofile(table.concat({modpath, ...}, DIR_DELIM) .. ".lua") + return dofile(table.concat({ modpath, ... }, DIR_DELIM) .. ".lua") end, }