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 function extract(input: string): (number, { moonwave.Item }?)
local res = process.spawn("moonwave-extractor", { "extract", input }, { local res = process.spawn("moonwave-extractor", { "extract", input }, {
stdio = { stdio = {
stderr = "forward" stderr = "forward",
} },
}) })
if not res.ok then if not res.ok then

View file

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

View file

@ -4,10 +4,4 @@ local process = require("@lune/process")
local CommandBuilder = require("./util/exec") local CommandBuilder = require("./util/exec")
process.exit( process.exit(CommandBuilder.new("stylua"):withArg("."):withArgs(process.args):withStdioStrategy("forward"):exec().code)
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({ local STYLE = table.freeze({
suite = function(name: string) suite = function(name: string)
return `{stdio.style("bold")}{stdio.color("purple")}SUITE{stdio.style( return `{stdio.style("bold")}{stdio.color("purple")}SUITE{stdio.style("reset")} {name}`
"reset"
)} {name}`
end, end,
report = function( report = function(name: string, state: "success" | "error" | "skip", elapsed: number)
name: string,
state: "success" | "error" | "skip",
elapsed: number
)
local state_color: stdio.Color = if state == "success" local state_color: stdio.Color = if state == "success"
then "green" then "green"
elseif state == "error" then "red" elseif state == "error" then "red"
elseif state == "skip" then "yellow" elseif state == "skip" then "yellow"
else error("Invalid test state") else error("Invalid test state")
return ` {stdio.style("bold")}{stdio.color(state_color)}{if state return ` {stdio.style("bold")}{stdio.color(state_color)}{if state == "skip" then "SKIP" else "TEST"}{stdio.style(
== "skip" "reset"
then "SKIP" )} {name} [{stdio.style("dim")}{string.format("%.2fms", elapsed)}{stdio.style("reset")}]`
else "TEST"}{stdio.style("reset")} {name} [{stdio.style("dim")}{string.format(
"%.2fms",
elapsed
)}{stdio.style("reset")}]`
end, end,
}) })

View file

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