From 41352cbb178aa16cd6bb01f3517606196f1c8f1f Mon Sep 17 00:00:00 2001 From: Robert Jelic Date: Sun, 9 Feb 2025 15:35:23 +0100 Subject: [PATCH] Test --- .github/workflows/minify.yml | 35 ++++++++++++++++++++++++++--------- src/main.lua | 1 + 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/.github/workflows/minify.yml b/.github/workflows/minify.yml index ea8ce06..d8f27be 100644 --- a/.github/workflows/minify.yml +++ b/.github/workflows/minify.yml @@ -35,32 +35,49 @@ jobs: local lfs = require("lfs") local files = {} - for file in lfs.dir("src") do - if file:match("%.lua$") then - table.insert(files, file) + + local function scanDir(dir, baseDir) + baseDir = baseDir or "" + for file in lfs.dir(dir) do + if file ~= "." and file ~= ".." then + local fullPath = dir .. "/" .. file + local attr = lfs.attributes(fullPath) + if attr.mode == "directory" then + scanDir(fullPath, baseDir .. file .. "/") + elseif file:match("%.lua$") then + table.insert(files, { + path = baseDir .. file, + fullPath = fullPath + }) + end + end end end + scanDir("src") + local output = { 'local minified = true\n', - 'local project = {}\n' + 'local project = {}\n', + 'local baseRequire = require\n', + 'require = function(path) return project[path] or baseRequire(path) end\n' } for _, file in ipairs(files) do - local f = io.open("src/" .. file, "r") + local f = io.open(file.fullPath, "r") local content = f:read("*all") f:close() local success, minified = minify(content) if not success then - print("Failed to minify " .. file) + print("Failed to minify " .. file.path) print(minified) os.exit(1) end table.insert(output, string.format( 'project["%s"] = function(...) %s end\n', - file, minified + file.path, minified )) end @@ -77,8 +94,8 @@ jobs: echo "Running minification..." if lua minify_script.lua; then echo "Minification successful" - echo "Minified content:" - cat release/project.min.lua + echo "Files processed:" + find src -name "*.lua" | sed 's|^src/||' else echo "Minification failed" exit 1 diff --git a/src/main.lua b/src/main.lua index 6574f2c..e720a9f 100644 --- a/src/main.lua +++ b/src/main.lua @@ -112,5 +112,6 @@ function basalt.run(isActive) end end end +basalt.autoUpdate = basalt.run return basalt \ No newline at end of file