From 23b399903333b9a93ef753de4d4b1d36a4ffdfa8 Mon Sep 17 00:00:00 2001 From: dnlcrl Date: Fri, 12 May 2023 11:35:59 +0200 Subject: [PATCH] add also a check for commits.lengths --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 9001f92..7da1cf6 100644 --- a/index.js +++ b/index.js @@ -41,7 +41,7 @@ const pkg = getPackageJson(); let messages = [] if (checkLastCommitOnly === 'true') { console.log('Only checking the last commit...'); - const commit = event.commits ? event.commits[event.commits.length - 1] : null; + const commit = event.commits && event.commits.lengths > 0 ? event.commits[event.commits.length - 1] : null; messages = commit ? [commit.message + '\n' + commit.body] : []; } else { messages = event.commits ? event.commits.map((commit) => commit.message + '\n' + commit.body) : [];