Skip to content

Commit 4eaea5c

Browse files
committed
refactor main.ts to improve command execution output handling and error reporting
1 parent 08e29c8 commit 4eaea5c

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

dist/index.js

Lines changed: 10 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { analyze } from "./scripts/analyze";
55
import { formatting } from "./scripts/formatting";
66
import { testing } from "./scripts/testing";
77
import { comment } from "./scripts/comment";
8-
import { cwd, chdir } from "process";
8+
import { cwd, chdir, listeners } from "process";
99
// import { coverage } from './scripts/coverage'
1010
import minimist from "minimist";
1111

@@ -17,16 +17,23 @@ export const runCommand = async (
1717
command: string,
1818
label: string,
1919
): Promise<string | boolean> => {
20+
let output = "";
2021
try {
21-
await exec(command);
22+
await exec(command, [], {
23+
listeners: {
24+
stdout: (data) => {
25+
output += data.toString();
26+
},
27+
},
28+
});
2229
return false;
2330
} catch (error: unknown) {
2431
if (error instanceof Error) {
2532
debug(`${label} failed: ${error.message}`);
26-
return error.message;
33+
return output;
2734
} else if (typeof error === "string") {
2835
debug(`${label} failed: ${error}`);
29-
return error;
36+
return output;
3037
} else {
3138
return true;
3239
}

0 commit comments

Comments
 (0)