From a07dd0aa5d976b955f41dc49927c721c7b912552 Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Tue, 22 Oct 2024 15:02:48 -0400 Subject: [PATCH] cli: Fix `jetpack changelog add` on a release branch When running `jetpack changelog add` while on a release branch, the script should not throw an error about attempting to access `.length` on `undefined`. --- tools/cli/commands/changelog.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/cli/commands/changelog.js b/tools/cli/commands/changelog.js index 9319a3e1c6843..5b24a6c7237f5 100644 --- a/tools/cli/commands/changelog.js +++ b/tools/cli/commands/changelog.js @@ -311,7 +311,8 @@ async function changelogAdd( argv ) { return; } - let changelogInfo, needChangelog; + let changelogInfo, + needChangelog = []; if ( argv.project ) { needChangelog = [ argv.project ]; @@ -695,7 +696,11 @@ async function checkChangelogFiles() { const branchReg = /\/branch-/; // match example: jetpack/branch-1.2.3 if ( currentBranch.match( branchReg ) ) { console.log( chalk.green( 'Release branch detected. No changelog required.' ) ); - return []; + return { + touched: [], + files: new Map(), + need: [], + }; } const re1 = /^projects\/([^/]+\/[^/]+)\//; // regex matches project file path, ie 'project/packages/connection/..'