Skip to content

Commit

Permalink
refactor main.ts to improve command execution output handling and err…
Browse files Browse the repository at this point in the history
…or reporting
  • Loading branch information
DE7924 committed Dec 12, 2024
1 parent 08e29c8 commit 4eaea5c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
13 changes: 10 additions & 3 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.

15 changes: 11 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { analyze } from "./scripts/analyze";
import { formatting } from "./scripts/formatting";
import { testing } from "./scripts/testing";
import { comment } from "./scripts/comment";
import { cwd, chdir } from "process";
import { cwd, chdir, listeners } from "process";

Check failure on line 8 in src/main.ts

View workflow job for this annotation

GitHub Actions / code-quality

'listeners' is defined but never used
// import { coverage } from './scripts/coverage'
import minimist from "minimist";

Expand All @@ -17,16 +17,23 @@ export const runCommand = async (
command: string,
label: string,
): Promise<string | boolean> => {
let output = "";
try {
await exec(command);
await exec(command, [], {
listeners: {
stdout: (data) => {
output += data.toString();
},
},
});
return false;
} catch (error: unknown) {
if (error instanceof Error) {
debug(`${label} failed: ${error.message}`);
return error.message;
return output;
} else if (typeof error === "string") {
debug(`${label} failed: ${error}`);
return error;
return output;
} else {
return true;
}
Expand Down

0 comments on commit 4eaea5c

Please sign in to comment.