This commit is contained in:
Gvidas Juknevičius 2024-08-26 00:03:08 +03:00
parent b88ca058fa
commit d07a35f360
Signed by: MCorange
GPG Key ID: 12B1346D720B7FBB
2 changed files with 17 additions and 13 deletions

View File

@ -3,11 +3,11 @@ local __DEFAULT_IMPORT = require
local require = function(path) local require = function(path)
if __BUNDLER_FILES[path] then if __BUNDLER_FILES[path] then
return __BUNDLER_FILES[path]() return __BUNDLER_FILES[path]()
else elseif __BUNDLER_FILES[path .. ".lua"]
return __DEFAULT_IMPORT(path) return __DEFAULT_IMPORT(path .. ".lua")
end end
end end
local __UPDATE_HASH = "4db13421e8f5b57961154b92098c42a237ebcdcf" local __UPDATE_HASH = "7384b0fb8aa0c196aa226eb2e3d2d7a18d323eaa"
rawset(__BUNDLER_FILES, "updater.lua", function () rawset(__BUNDLER_FILES, "updater.lua", function ()
local utils = require("utils.lua") local utils = require("utils.lua")
local config = require("config.lua") local config = require("config.lua")

24
x.py
View File

@ -40,18 +40,22 @@ def get_hash(buf: str) -> str:
hasher.update(bytes(buf, "utf-8")); hasher.update(bytes(buf, "utf-8"));
return hasher.hexdigest(); return hasher.hexdigest();
REQ_HEADER = """
local __BUNDLER_FILES = {}
local __DEFAULT_IMPORT = require
local require = function(path)
if __BUNDLER_FILES[path] then
return __BUNDLER_FILES[path]()
elseif __BUNDLER_FILES[path .. ".lua"]
return __DEFAULT_IMPORT(path .. ".lua")
end
end
local __UPDATE_HASH = __BUNDLER_REPLACE_HASH__
"""
def main(): def main():
buf = "" buf = ""
buf += "local __BUNDLER_FILES = {}\n"; buf += REQ_HEADER;
buf += "local __DEFAULT_IMPORT = require\n";
buf += "local require = function(path)\n";
buf += " if __BUNDLER_FILES[path] then\n";
buf += " return __BUNDLER_FILES[path]()\n";
buf += " else\n";
buf += " return __DEFAULT_IMPORT(path)\n";
buf += " end\n";
buf += "end\n";
buf += "local __UPDATE_HASH = __BUNDLER_REPLACE_HASH__\n";
for file in FILES: for file in FILES:
print(f"=== FILE: {file}"); print(f"=== FILE: {file}");
buf += read_file(file); buf += read_file(file);