From 539558909e73fb86ac5efd15c3fedcda48fbdc71 Mon Sep 17 00:00:00 2001 From: Dan Bjorge Date: Thu, 20 Jun 2024 17:23:53 -0400 Subject: [PATCH] fix: avoid "Error: Not Found" when octokit gives status as string instead of number (#46) Minimal fix to get usage unblocked, separate PR for following up on getting deps updated/pinned Closes #45 Demo of fix working: https://github.com/dequelabs/dbjorge-test-repo/actions/runs/9603704409/job/26487539207 ## Reviewer checks **Required fields, to be filled out by PR reviewer(s)** - [x] Follows the commit message policy, appropriate for next version - [x] Code is reviewed for security --- src/main.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main.ts b/src/main.ts index a64b599..616447b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -35,7 +35,12 @@ async function run(): Promise { }) pullRequestTemplate = response.data } catch (err) { - if (err.status === 404 && err.message === 'Not Found') { + // Careful; `err.status` can be either a string or a number depending on + // octokit version. + if ( + String(err.status) === '404' && + err.message === 'Not Found' + ) { console.log( `Unable to find pr-template "${template}"` )