add also a check for commits.lengths

This commit is contained in:
dnlcrl 2023-05-12 11:35:59 +02:00
parent affc39eb17
commit 23b3999033
1 changed files with 1 additions and 1 deletions

View File

@ -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) : [];