@@ -2,6 +2,7 @@ import os from 'os';
22import path from 'path' ;
33import forEach from 'lodash/forEach' ;
44import { cliux } from '@contentstack/cli-utilities' ;
5+ import chalk from 'chalk' ;
56import { MergeInputOptions , MergeSummary } from '../interfaces' ;
67import {
78 selectMergeStrategy ,
@@ -107,6 +108,10 @@ export default class MergeHandler {
107108 deleted : [ ] ,
108109 } ;
109110 const selectedItems = await selectCustomPreferences ( module , this . branchCompareData [ module ] ) ;
111+ if ( ! selectedItems . length ) {
112+ cliux . print ( chalk . red ( 'No items were selected' ) ) ;
113+ process . exit ( 1 ) ;
114+ }
110115 forEach ( selectedItems , ( item ) => {
111116 this . mergeSettings . mergeContent [ module ] [ item . status ] . push ( item . value ) ;
112117 this . mergeSettings . itemMergeStrategies . push ( item . value ) ;
@@ -132,8 +137,11 @@ export default class MergeHandler {
132137 } else if ( this . strategy === 'overwrite_with_compare' ) {
133138 this . mergeSettings . strategy = 'overwrite_with_compare' ;
134139 }
135-
136- await this . displayMergeSummary ( ) ;
140+ if ( this . checkEmptySelection ( ) ) {
141+ cliux . print ( chalk . red ( 'No items selected' ) ) ;
142+ } else {
143+ await this . displayMergeSummary ( ) ;
144+ }
137145
138146 if ( ! this . executeOption ) {
139147 const executionResponse = await selectMergeExecution ( ) ;
@@ -152,6 +160,17 @@ export default class MergeHandler {
152160 }
153161 }
154162
163+ checkEmptySelection ( ) {
164+ for ( let module in this . branchCompareData ) {
165+ if ( this . mergeSettings . mergeContent [ module ] ?. modified ?. length
166+ || this . mergeSettings . mergeContent [ module ] ?. added ?. length
167+ || this . mergeSettings . mergeContent [ module ] ?. deleted ?. length ) {
168+ return false ;
169+ }
170+ }
171+ return true ;
172+ }
173+
155174 displayMergeSummary ( ) {
156175 if ( this . mergeSettings . strategy !== 'ignore' ) {
157176 for ( let module in this . branchCompareData ) {
0 commit comments