From ac0732423a0864045d7d68c89619dc0adffe895a Mon Sep 17 00:00:00 2001 From: Adam Matthiesen Date: Thu, 14 Mar 2024 09:23:38 -0700 Subject: [PATCH] Refactor getGistFile function to handle null and missing files --- package/src/lib/octokit.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/package/src/lib/octokit.ts b/package/src/lib/octokit.ts index 82e4962..1dc0439 100644 --- a/package/src/lib/octokit.ts +++ b/package/src/lib/octokit.ts @@ -99,11 +99,9 @@ export const getGistFile = async ( filename: string ) => { const gist = await gistGrabber(gistId); - if (gist?.files){ - const file = gist.files[filename]; - return file - } - return null; + if (gist === null) return null; + if (!gist.files) return null; + return gist.files[filename]; }; // Get a Group of Gist files by ID