From d91981539771934da208a83eacfae25d810c6a38 Mon Sep 17 00:00:00 2001 From: Jacob Heider Date: Wed, 11 Jan 2023 18:50:57 -0500 Subject: [PATCH] better undefined resolution --- scripts/fetch-pr-artifacts.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/fetch-pr-artifacts.ts b/scripts/fetch-pr-artifacts.ts index 4558bf08..595881fc 100755 --- a/scripts/fetch-pr-artifacts.ts +++ b/scripts/fetch-pr-artifacts.ts @@ -52,7 +52,9 @@ export async function find_pr(repo: string, ref: string): Promise(prQuery(repo)) const node = res.repository?.ref?.target?.history?.edges.find(n => n.node.oid === ref) - return node?.node.associatedPullRequests.nodes[0].number + const nodes = node?.node.associatedPullRequests.nodes + if (!nodes || nodes.length === 0) return + return nodes[0].number } async function queryGraphQL(query: string): Promise {