From 748071360e629e61deb0140e7974a5b7fa43488f Mon Sep 17 00:00:00 2001 From: Daniel Eshkeri Date: Thu, 12 Dec 2024 16:04:44 +0000 Subject: [PATCH] refactor error handling in analyze.ts, update comment formatting in comment.ts, and remove debug flag from test command in testing.ts --- src/scripts/analyze.ts | 6 +++++- src/scripts/comment.ts | 8 ++++---- src/scripts/testing.ts | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/scripts/analyze.ts b/src/scripts/analyze.ts index 5307c8f6..ebbf3882 100644 --- a/src/scripts/analyze.ts +++ b/src/scripts/analyze.ts @@ -13,8 +13,12 @@ const runCommand = async ( if (error instanceof Error) { debug(`${label} failed: ${error.message}`); return error.message; + } else if (typeof error === "string") { + debug(`${label} failed: ${error}`); + return error; + } else { + return true; } - return true; } }; diff --git a/src/scripts/comment.ts b/src/scripts/comment.ts index 70b79f32..f8541da7 100644 --- a/src/scripts/comment.ts +++ b/src/scripts/comment.ts @@ -12,10 +12,10 @@ export const comment = async ( ): Promise => { try { const commentBody = ` - ## PR Checks Complete\n - ${analyzeStr?.output}\n - ${codeFormattingStr?.output}\n - ${testingStr?.output}\n`; +## PR Checks Complete\n +${analyzeStr?.output}\n +${codeFormattingStr?.output}\n +${testingStr?.output}\n`; // ## Coverage = ${coverageStr?.output}\n` await ocotokit.rest.issues.createComment({ diff --git a/src/scripts/testing.ts b/src/scripts/testing.ts index fd061cb5..ab1bbe2d 100644 --- a/src/scripts/testing.ts +++ b/src/scripts/testing.ts @@ -5,7 +5,7 @@ import { stepResponse } from "src/main"; export const testing = async (): Promise => { try { // Run tests and generate coverage - await exec("npm run test -- --coverage --debug"); + await exec("npm run test -- --coverage"); // Test tsdoc await exec("npm run docs");