chore: fix bundle script path filtering

This commit is contained in:
Erica Marigold 2024-03-30 11:23:04 +05:30
parent 4bc535a135
commit d4d16639b5
No known key found for this signature in database
GPG key ID: 2768CC0C23D245D1

View file

@ -5,6 +5,7 @@ local task = require("@lune/task")
local terracotta = require("terracotta") local terracotta = require("terracotta")
local LUAU_TYPES_PATH = "out/rbxts/init.luau" local LUAU_TYPES_PATH = "out/rbxts/init.luau"
local TS_TYPES_PATH = "out/rbxts/index.d.ts"
local function map<k, v>(tbl: { [k]: v }, callback: (k: k, v: v) -> v) local function map<k, v>(tbl: { [k]: v }, callback: (k: k, v: v) -> v)
for k, v in tbl do for k, v in tbl do
@ -26,7 +27,7 @@ print("\n")
local dirChildren = fs.readDir("out/rbxts") local dirChildren = fs.readDir("out/rbxts")
local ENTYRPOINTS = map(dirChildren, function(k, path) local ENTYRPOINTS = map(dirChildren, function(k, path)
if path ~= "rbxts" and path:find("%.lua.$") then if path ~= "rbxts" and path:find("%.lua.?$") then
print(`{k}/{#dirChildren} include`, path) print(`{k}/{#dirChildren} include`, path)
return "out/rbxts/" .. path return "out/rbxts/" .. path
end end
@ -52,16 +53,18 @@ function main()
print(`\nbundled {#ENTYRPOINTS} files in {os.clock() - bundleStart}s`) print(`\nbundled {#ENTYRPOINTS} files in {os.clock() - bundleStart}s`)
local fsStart = os.clock() local fsStart = os.clock()
for pos, path in ENTYRPOINTS do for pos, path in { table.unpack(ENTYRPOINTS), TS_TYPES_PATH } do
local bundle = out[path] local bundle = out[path]
if path == LUAU_TYPES_PATH then if path == LUAU_TYPES_PATH then
bundle = fs.readFile(LUAU_TYPES_PATH) bundle = fs.readFile(LUAU_TYPES_PATH)
elseif path == TS_TYPES_PATH then
bundle = fs.readFile(LUAU_TYPES_PATH)
end end
path = "out/" .. path:split("/")[3] path = "out/" .. path:split("/")[3]
stdio.write(`\x1B[2K\r{pos}/{#ENTYRPOINTS} write {path}`) stdio.write(`\x1B[2K\r{pos}/{#ENTYRPOINTS} write {path}`)
task.wait(0.1) task.wait(1)
fs.writeFile(path, bundle) fs.writeFile(path, bundle)
end end