Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lua/guard/_meta.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
---@field env table<string, string>?
---@field timeout integer?
---@field health function?
---@field stderr boolean?
---@field ignore_exit_code boolean?

---@alias LintConfig LintConfigTable|fun(): LintConfigTable

Expand Down
6 changes: 3 additions & 3 deletions lua/guard/lint.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ local custom_ns = {}
---@async
---@param cmd string[]
---@param cwd string
---@param config {env: table?, timeout: integer?}
---@param config {env: table?, timeout: integer?, stderr: boolean?, ignore_exit_code: boolean?}
---@param input string|string[]
---@return string output
---@return {code: integer, stderr: string, cmd: string}? error
Expand All @@ -31,15 +31,15 @@ local function exec_linter(cmd, cwd, config, input)
handle:write(nil)
end)

if result.code ~= 0 and #result.stderr > 0 then
if not config.ignore_exit_code and result.code ~= 0 and #result.stderr > 0 then
return '', {
code = result.code,
stderr = result.stderr,
cmd = cmd[1],
}
end

return result.stdout, nil
return config.stderr and result.stderr or result.stdout, nil
end

---@param buf number?
Expand Down
2 changes: 2 additions & 0 deletions lua/guard/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ function M.toolcopy(c)
timeout = c.timeout,
parse = c.parse,
health = c.health,
stderr = c.stderr,
ignore_exit_code = c.ignore_exit_code,
}
end

Expand Down
Loading