mirror of
https://github.com/0x5eal/luau-unzip.git
synced 2025-05-04 11:23:48 +01:00
style: apply stylua
formatter
This commit is contained in:
parent
cc6a56d2d4
commit
5d123d0459
9 changed files with 514 additions and 550 deletions
|
@ -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
|
||||
|
|
|
@ -20,5 +20,5 @@ return {
|
|||
local fmtMsg = stdio.format(styleMappings[type], ...)
|
||||
|
||||
return writer(fmtMsg .. "\n")
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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,
|
||||
})
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue