mirror of
https://github.com/golangci/golangci-lint-action.git
synced 2026-02-25 00:51:49 +00:00
pass json through to output
This commit is contained in:
parent
0e8f5bf773
commit
74044faec7
1 changed files with 20 additions and 3 deletions
23
src/run.ts
23
src/run.ts
|
|
@ -103,12 +103,28 @@ type ExecRes = {
|
||||||
stderr: string
|
stderr: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const printJSONLines = (s: string): void => {
|
||||||
|
const lines = s.split(`\n`).filter((line) => line.length > 0)
|
||||||
|
for (const line of lines) {
|
||||||
|
if (line.startsWith(`::`)) {
|
||||||
|
core.info(line)
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const obj = JSON.parse(line)
|
||||||
|
core.setOutput('json', JSON.stringify(obj, null, 2))
|
||||||
|
} catch (err) {
|
||||||
|
core.info(line)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const printOutput = (res: ExecRes): void => {
|
const printOutput = (res: ExecRes): void => {
|
||||||
if (res.stdout) {
|
if (res.stdout) {
|
||||||
core.info(res.stdout)
|
printJSONLines(res.stdout)
|
||||||
}
|
}
|
||||||
if (res.stderr) {
|
if (res.stderr) {
|
||||||
core.info(res.stderr)
|
printJSONLines(res.stderr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -137,8 +153,9 @@ async function runLint(lintPath: string, patchPath: string): Promise<void> {
|
||||||
.trim()
|
.trim()
|
||||||
.split(",")
|
.split(",")
|
||||||
.filter((f) => f.length > 0)
|
.filter((f) => f.length > 0)
|
||||||
.filter((f) => !f.startsWith(`github-actions`))
|
.filter((f) => !f.startsWith(`github-actions`) && !f.startsWith(`json`))
|
||||||
.concat("github-actions")
|
.concat("github-actions")
|
||||||
|
.concat("json")
|
||||||
.join(",")
|
.join(",")
|
||||||
|
|
||||||
addedArgs.push(`--out-format=${formats}`)
|
addedArgs.push(`--out-format=${formats}`)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue