File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
packages/contentstack-import/src/commands/cm/stacks Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -148,6 +148,22 @@ export default class ImportCommand extends Command {
148148 backupDir = importConfig . cliLogsPath || importConfig . backupDir ;
149149
150150 const managementAPIClient : ContentstackClient = await managementSDKClient ( importConfig ) ;
151+
152+ if ( ! flags . branch ) {
153+ try {
154+ const branches = await managementAPIClient
155+ . stack ( { api_key : importConfig . apiKey } )
156+ . branch ( )
157+ . query ( )
158+ . find ( )
159+ . then ( ( { items } : any ) => items )
160+ if ( branches . length ) {
161+ flags . branch = 'main' ;
162+ }
163+ } catch ( error ) {
164+ // Branch not enabled, just the let flow continue
165+ }
166+ }
151167 const moduleImporter = new ModuleImporter ( managementAPIClient , importConfig ) ;
152168 const result = await moduleImporter . start ( ) ;
153169
You can’t perform that action at this time.
0 commit comments