Skip to content

Commit

Permalink
fix build script
Browse files Browse the repository at this point in the history
fix project name
  • Loading branch information
howmanysmall committed Aug 12, 2024
1 parent f900438 commit af930bf
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 5 deletions.
44 changes: 44 additions & 0 deletions .lune/BuildRelease.luau
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,43 @@ local stdio = require("@lune/stdio")
local PROJECT_NAME = "built-release.project.json"
local SOURCEMAP_NAME = "built-sourcemap.json"

local EXTRA_STEPS: {
{
Enabled: boolean,
Name: string,
Function: (builtProject: FileInstance.FileInstance) -> boolean,
}
} =
{
{
Enabled = true;
Name = "Fix Promise import";
Function = function(builtProject)
local promise = builtProject:FindFirstFile("Promise.luau")
if not promise then
return false
end

local promiseFileSource = promise:Read()
if not promiseFileSource then
return false
end

promise:Write(
(
string.gsub(
promiseFileSource,
"local Packages = script.Parent.Parent",
"local Packages = script.Parent.Packages"
)
)
)

return true
end;
};
}

type Cleanup = () -> ()

local function CreateBuildProject(): Cleanup
Expand Down Expand Up @@ -55,6 +92,13 @@ local function CreateBuildProject(): Cleanup
end
end

for _, extraStep in EXTRA_STEPS do
if not extraStep.Enabled then
continue
end
extraStep.Function(builtProject)
end

if not fs.isFile(PROJECT_NAME) then
local json = serde.encode("json", {
globIgnorePaths = {
Expand Down
10 changes: 6 additions & 4 deletions .lune/Classes/FileInstance.luau
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,10 @@ function Private:GetDescendants()
end

function FileInstance:FindFirstFile(name, recursive)
name = PathUtilities.Join(self.Name, name)
if recursive then
for _, descendant in self:GetDescendants() do
if descendant.Name == name then
if PathUtilities.OsPath(descendant.Name) == name then
return descendant
end
end
Expand All @@ -153,17 +154,18 @@ function FileInstance:FindFirstFile(name, recursive)
end

for _, child in self:GetChildren() do
if child.Name == name then
if PathUtilities.OsPath(child.Name) == name then
return child
end
end

return nil
end
function FileInstance:FindFirstDirectory(name, recursive)
name = PathUtilities.Join(self.Name, name)
if recursive then
for _, descendant in self:GetDescendants() do
if descendant.IsDirectory and descendant.Name == name then
if descendant.IsDirectory and PathUtilities.OsPath(descendant.Name) == name then
return descendant
end
end
Expand All @@ -172,7 +174,7 @@ function FileInstance:FindFirstDirectory(name, recursive)
end

for _, child in self:GetChildren() do
if child.IsDirectory and child.Name == name then
if child.IsDirectory and PathUtilities.OsPath(child.Name) == name then
return child
end
end
Expand Down
2 changes: 1 addition & 1 deletion default.project.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "Janitor",
"name": "janitor",
"tree": {
"$path": "src"
}
Expand Down

0 comments on commit af930bf

Please sign in to comment.