style: apply stylua formatter

This commit is contained in:
Erica Marigold 2025-02-21 19:46:57 +00:00
parent cc6a56d2d4
commit 5d123d0459
Signed by: DevComp
SSH key fingerprint: SHA256:jD3oMT4WL3WHPJQbrjC3l5feNCnkv7ndW8nYaHX5wFw
9 changed files with 514 additions and 550 deletions

View file

@ -10,8 +10,8 @@ local writeMarkdown = require("./markdown")
local function extract(input: string): (number, { moonwave.Item }?)
local res = process.spawn("moonwave-extractor", { "extract", input }, {
stdio = {
stderr = "forward"
}
stderr = "forward",
},
})
if not res.ok then

View file

@ -20,5 +20,5 @@ return {
local fmtMsg = stdio.format(styleMappings[type], ...)
return writer(fmtMsg .. "\n")
end
end,
}

View file

@ -4,10 +4,4 @@ local process = require("@lune/process")
local CommandBuilder = require("./util/exec")
process.exit(
CommandBuilder.new("stylua")
:withArg(".")
:withArgs(process.args)
:withStdioStrategy("forward")
:exec().code
)
process.exit(CommandBuilder.new("stylua"):withArg("."):withArgs(process.args):withStdioStrategy("forward"):exec().code)

View file

@ -9,28 +9,18 @@ local watch = require("../util/channel")
local STYLE = table.freeze({
suite = function(name: string)
return `{stdio.style("bold")}{stdio.color("purple")}SUITE{stdio.style(
"reset"
)} {name}`
return `{stdio.style("bold")}{stdio.color("purple")}SUITE{stdio.style("reset")} {name}`
end,
report = function(
name: string,
state: "success" | "error" | "skip",
elapsed: number
)
report = function(name: string, state: "success" | "error" | "skip", elapsed: number)
local state_color: stdio.Color = if state == "success"
then "green"
elseif state == "error" then "red"
elseif state == "skip" then "yellow"
else error("Invalid test state")
return ` {stdio.style("bold")}{stdio.color(state_color)}{if state
== "skip"
then "SKIP"
else "TEST"}{stdio.style("reset")} {name} [{stdio.style("dim")}{string.format(
"%.2fms",
elapsed
)}{stdio.style("reset")}]`
return ` {stdio.style("bold")}{stdio.color(state_color)}{if state == "skip" then "SKIP" else "TEST"}{stdio.style(
"reset"
)} {name} [{stdio.style("dim")}{string.format("%.2fms", elapsed)}{stdio.style("reset")}]`
end,
})

View file

@ -5,10 +5,7 @@ local stdio = require("@lune/stdio")
local CommandBuilder = {}
export type CommandBuilder = typeof(setmetatable(
{} :: CommandBuilderFields,
{ __index = CommandBuilder }
))
export type CommandBuilder = typeof(setmetatable({} :: CommandBuilderFields, { __index = CommandBuilder }))
type CommandBuilderFields = {
program: string,
args: { string },
@ -37,18 +34,12 @@ function CommandBuilder.new(program: string)
)
end
function CommandBuilder.withArg(
self: CommandBuilder,
arg: string
): CommandBuilder
function CommandBuilder.withArg(self: CommandBuilder, arg: string): CommandBuilder
table.insert(self.args, arg)
return self
end
function CommandBuilder.withArgs(
self: CommandBuilder,
args: { string }
): CommandBuilder
function CommandBuilder.withArgs(self: CommandBuilder, args: { string }): CommandBuilder
for _, arg in args do
self:withArg(arg)
end
@ -69,9 +60,7 @@ function CommandBuilder.withStdioStrategy(
return self
end
local function intoSpawnOptionsStdioKind(
strategy: StdioStrategy
): process.SpawnOptionsStdioKind
local function intoSpawnOptionsStdioKind(strategy: StdioStrategy): process.SpawnOptionsStdioKind
if strategy == "pipe" then
return "default"
end
@ -88,11 +77,7 @@ local function intoSpawnOptionsStdioKind(
end
function CommandBuilder.exec(self: CommandBuilder): process.SpawnResult
print(
"$",
stdio.style("dim") .. self.program,
table.concat(self.args, " ") .. stdio.style("reset")
)
print("$", stdio.style("dim") .. self.program, table.concat(self.args, " ") .. stdio.style("reset"))
local function translateIoStrategyMappings(mappings: IoStrategyMapping)
local translatedMappings: process.SpawnOptionsStdio = {}
@ -105,16 +90,11 @@ function CommandBuilder.exec(self: CommandBuilder): process.SpawnResult
local child = process.spawn(self.program, self.args, {
shell = true,
stdio = translateIoStrategyMappings(
self.stdioStrategy or DEFAULT_STDIO_STRATEGY
),
stdio = translateIoStrategyMappings(self.stdioStrategy or DEFAULT_STDIO_STRATEGY),
})
if not child.ok then
print(
`\n{stdio.color("red")}[luau-lsp]{stdio.color("reset")} Exited with code`,
child.code
)
print(`\n{stdio.color("red")}[luau-lsp]{stdio.color("reset")} Exited with code`, child.code)
end
return child