This commit is contained in:
Thomas Gorham 2024-02-02 12:38:10 -08:00
parent 74044faec7
commit 7b740943db
3 changed files with 42 additions and 10 deletions

22
dist/post_run/index.js generated vendored
View file

@ -90897,12 +90897,27 @@ async function prepareEnv() {
core.info(`Prepared env in ${Date.now() - startedAt}ms`);
return { lintPath, patchPath };
}
const printOutputAndForwardJSON = (s) => {
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) => {
if (res.stdout) {
core.info(res.stdout);
printOutputAndForwardJSON(res.stdout);
}
if (res.stderr) {
core.info(res.stderr);
printOutputAndForwardJSON(res.stderr);
}
};
async function runLint(lintPath, patchPath) {
@ -90926,8 +90941,9 @@ async function runLint(lintPath, patchPath) {
.trim()
.split(",")
.filter((f) => f.length > 0)
.filter((f) => !f.startsWith(`github-actions`))
.filter((f) => !f.startsWith(`github-actions`) && !f.startsWith(`json`))
.concat("github-actions")
.concat("json")
.join(",");
addedArgs.push(`--out-format=${formats}`);
userArgs = userArgs.replace(/--out-format=\S*/gi, "").trim();

22
dist/run/index.js generated vendored
View file

@ -90897,12 +90897,27 @@ async function prepareEnv() {
core.info(`Prepared env in ${Date.now() - startedAt}ms`);
return { lintPath, patchPath };
}
const printOutputAndForwardJSON = (s) => {
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) => {
if (res.stdout) {
core.info(res.stdout);
printOutputAndForwardJSON(res.stdout);
}
if (res.stderr) {
core.info(res.stderr);
printOutputAndForwardJSON(res.stderr);
}
};
async function runLint(lintPath, patchPath) {
@ -90926,8 +90941,9 @@ async function runLint(lintPath, patchPath) {
.trim()
.split(",")
.filter((f) => f.length > 0)
.filter((f) => !f.startsWith(`github-actions`))
.filter((f) => !f.startsWith(`github-actions`) && !f.startsWith(`json`))
.concat("github-actions")
.concat("json")
.join(",");
addedArgs.push(`--out-format=${formats}`);
userArgs = userArgs.replace(/--out-format=\S*/gi, "").trim();

View file

@ -103,7 +103,7 @@ type ExecRes = {
stderr: string
}
const printJSONLines = (s: string): void => {
const printOutputAndForwardJSON = (s: string): void => {
const lines = s.split(`\n`).filter((line) => line.length > 0)
for (const line of lines) {
if (line.startsWith(`::`)) {
@ -112,7 +112,7 @@ const printJSONLines = (s: string): void => {
try {
const obj = JSON.parse(line)
core.setOutput('json', JSON.stringify(obj, null, 2))
core.setOutput("JSON", JSON.stringify(obj, null, 2))
} catch (err) {
core.info(line)
}
@ -121,10 +121,10 @@ const printJSONLines = (s: string): void => {
const printOutput = (res: ExecRes): void => {
if (res.stdout) {
printJSONLines(res.stdout)
printOutputAndForwardJSON(res.stdout)
}
if (res.stderr) {
printJSONLines(res.stderr)
printOutputAndForwardJSON(res.stderr)
}
}