mirror of
https://github.com/pesde-pkg/scripts.git
synced 2024-12-13 23:40:35 +00:00
fix(rojo): move action map to top level and lazily evaluate
This commit is contained in:
parent
a6a52cac3b
commit
3a160c3e22
1 changed files with 23 additions and 19 deletions
|
@ -5,6 +5,28 @@ local stdio = require("@lune/stdio")
|
||||||
|
|
||||||
local PLATFORM_SEP = if process.os == "windows" then "\\" else "/"
|
local PLATFORM_SEP = if process.os == "windows" then "\\" else "/"
|
||||||
|
|
||||||
|
-- A mapping of things to do depending on the file present
|
||||||
|
local PATH_ACTION_MAP: { [string]: (dir: string) -> number? } = {
|
||||||
|
["default.project.json"] = function(dir)
|
||||||
|
return process.spawn("rojo", { "sourcemap", dir }, {
|
||||||
|
cwd = process.cwd,
|
||||||
|
env = process.env,
|
||||||
|
stdio = "forward",
|
||||||
|
}).code
|
||||||
|
end,
|
||||||
|
|
||||||
|
["init.lua"] = function()
|
||||||
|
return stdio.write(
|
||||||
|
serde.encode("json", { filePaths = { "init.lua" } }, false)
|
||||||
|
)
|
||||||
|
end,
|
||||||
|
["init.luau"] = function()
|
||||||
|
return stdio.write(
|
||||||
|
serde.encode("json", { filePaths = { "init.luau" } }, false)
|
||||||
|
)
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
|
||||||
--- Writes a Rojo sourcemap for the project in the provided directory or the current
|
--- Writes a Rojo sourcemap for the project in the provided directory or the current
|
||||||
--- working directory to standard output.
|
--- working directory to standard output.
|
||||||
|
|
||||||
|
@ -14,24 +36,6 @@ local PLATFORM_SEP = if process.os == "windows" then "\\" else "/"
|
||||||
return function(packageDirectory: string?): boolean
|
return function(packageDirectory: string?): boolean
|
||||||
packageDirectory = packageDirectory or process.cwd
|
packageDirectory = packageDirectory or process.cwd
|
||||||
|
|
||||||
-- A mapping of things to do depending on the file present
|
|
||||||
local PATH_ACTION_MAP: { [string]: (dir: string) -> number? } = {
|
|
||||||
["default.project.json"] = function(dir)
|
|
||||||
return process.spawn("rojo", { "sourcemap", dir }, {
|
|
||||||
cwd = process.cwd,
|
|
||||||
env = process.env,
|
|
||||||
stdio = "forward",
|
|
||||||
}).code
|
|
||||||
end,
|
|
||||||
|
|
||||||
["init.lua"] = stdio.write(
|
|
||||||
serde.encode("json", { filePaths = { "init.lua" } }, false)
|
|
||||||
),
|
|
||||||
["init.luau"] = stdio.write(
|
|
||||||
serde.encode("json", { filePaths = { "init.luau" } }, false)
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
-- We go through the action mappings in order of priority and check for the
|
-- We go through the action mappings in order of priority and check for the
|
||||||
-- file predicates, if present, we execute the action and report our status
|
-- file predicates, if present, we execute the action and report our status
|
||||||
for path, action in PATH_ACTION_MAP do
|
for path, action in PATH_ACTION_MAP do
|
||||||
|
|
Loading…
Reference in a new issue