Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions src/lib.luau
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,39 @@ function multitarget.build(
local targetDir = pathfs.Directory.new(outputDir.path:join(target))
targetDir:writeDir() -- assure it exists (may not exist later if the user uses "includes" incorrectly, which would throw an undescriptive error later when trying to access this directory)

local globIgnore = {}
if buildFiles then
for _, buildFile in buildFiles do
local destination = targetDir.path:join(buildFile)
local parent = destination:parent()
if parent then
fs.writeDir(parent)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't this written already in line 240 above?

Copy link
Copy Markdown
Contributor Author

@ewd3v ewd3v Nov 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well yes in most cases the parent dir for a build file would be the targetDir, but if you input "modules/something.luau" as a build file then the parent dir would be "modules". So that code just makes sure the modules dir exist under the targetDir before writing (as fs.copy requires it).

end

fs.copy(buildFile, destination, true)

local wdFilePath = pathfs.canonicalize(buildFile):stripPrefix(workingDirPath)
if not wdFilePath then
continue
end

local wdFilePathStr = wdFilePath:toString()
if fs.isFile(buildFile) then
table.insert(globIgnore, wdFilePathStr)
elseif fs.isDir(buildFile) then
table.insert(globIgnore, wdFilePathStr .. "/**")
end
end
end

-- selene: allow(shadowing)
local newPesdeToml = tableHelper.copy(pesdeToml, true)
if newPesdeToml.includes then
for _, include in newPesdeToml.includes do
for _, path in
glob(include, {
cwd = workingDirPath,
ignore = globIgnore, -- We don't have to process these as everything in this list already got copied over in the step above
})
do
local dest = targetDir.path:join(
Expand Down Expand Up @@ -398,8 +424,8 @@ function multitarget.build(
end

for _, buildFile in buildFiles do
local darkluaOutputPath = targetDir.path:join(buildFile):toString()
darklua.process(buildFile, darkluaOutputPath, {
local targetBuildFile = targetDir.path:join(buildFile):toString()
darklua.process(targetBuildFile, targetBuildFile, {
rules = rules,
})
end
Expand Down