Skip to content

Commit

Permalink
output problem not on error
Browse files Browse the repository at this point in the history
  • Loading branch information
DE7924 committed Dec 13, 2024
1 parent 8edd47f commit 58aefb4
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 44 deletions.
35 changes: 15 additions & 20 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

42 changes: 19 additions & 23 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,38 +163,34 @@ const eslint = async (command: Command): Promise<stepResponse> => {
stdout: (data) => {
outputStr += data.toString();
},
stderr: (data) => {
outputStr += data.toString();
},
},
});
} catch (error) {
error = true;

Check failure on line 169 in src/main.ts

View workflow job for this annotation

GitHub Actions / code-quality

Do not assign to the exception parameter
setFailed(`Failed ${command.label}: ${error}`);

Check failure on line 170 in src/main.ts

View workflow job for this annotation

GitHub Actions / code-quality

Invalid type "unknown" of template literal expression
}

if (error) {
const lines = outputStr.split("\n");
const table = lines
.map((line) => {
const match = line.match(/^(.*?):(\d+):(\d+): (.*)$/);
if (match) {
const [_, file, line, column, message] = match;

Check failure on line 178 in src/main.ts

View workflow job for this annotation

GitHub Actions / code-quality

'_' is assigned a value but never used
return `<tr><td>${file}</td><td>${line}</td><td>${column}</td><td>${message}</td></tr>`;
}
return "";
})
.join("");

const problemCount = lines.filter((line) =>
line.match(/^(.*?):(\d+):(\d+): (.*)$/),
).length;

if (problemCount > 0) {
response.error = true;
// Parse the output to find errors and problems
const lines = outputStr.split("\n");
const table = lines
.map((line) => {
const match = line.match(/^(.*?):(\d+):(\d+): (.*)$/);
if (match) {
const [_, file, line, column, message] = match;
return `<tr><td>${file}</td><td>${line}</td><td>${column}</td><td>${message}</td></tr>`;
}
return "";
})
.join("");

const problemCount = lines.filter((line) =>
line.match(/^(.*?):(\d+):(\d+): (.*)$/),
).length;
response.output = `<p>${problemCount} problem${problemCount !== 1 ? "s" : ""} found</p><details><summary>See Details</summary><table><tr><th>File</th><th>Line</th><th>Column</th><th>Message</th></tr>${table}</table></details>`;
return response;
response.output = `<li>${failedEmoji} - ${command.label}: ${problemCount} problem${problemCount !== 1 ? "s" : ""} found\n<details><summary>See Details</summary><table><tr><th>File</th><th>Line</th><th>Column</th><th>Message</th></tr>${table}</table></details></li>`;
} else {
response.output = `<li>${passedEmoji} - ${command.label}\n</li>`;
return response;
}
return response;
};

0 comments on commit 58aefb4

Please sign in to comment.