@@ -508,23 +508,7 @@ export function addRestApi(cwd: string, settings: RestAPISettings) {
508508 } else {
509509 chain . sendCarriageReturn ( ) ;
510510 }
511- // Register a one-shot auto-responder for the optional overlap warning.
512- // When an overlap exists, the CLI prompts "...overlaps with...Are you sure you want to continue? (y/N)"
513- // before showing "Choose a lambda source". When no overlap exists, "Choose a lambda source" appears directly.
514- // We handle this by auto-responding 'y' to the overlap prompt via a data handler, so the single
515- // .wait('Choose a lambda source') works correctly in both cases without double-consuming the prompt.
516- let overlapHandled = false ;
517- chain
518- . wait ( 'Provide a path' , ( ) => {
519- chain . getProcess ( ) ?. addOnDataHandler ( ( data : string ) => {
520- if ( ! overlapHandled && / o v e r l a p s w i t h / . test ( data ) ) {
521- overlapHandled = true ;
522- chain . getProcess ( ) ?. write ( 'y' ) ;
523- }
524- } ) ;
525- } )
526- . sendCarriageReturn ( )
527- . wait ( 'Choose a lambda source' ) ;
511+ chain . wait ( 'Provide a path' ) . sendCarriageReturn ( ) . wait ( 'Choose a lambda source' ) ;
528512
529513 if ( settings . existingLambda ) {
530514 chain
@@ -620,26 +604,14 @@ export function updateRestApi(cwd: string, settings: Partial<typeof updateRestAp
620604 chain . wait ( 'A migration is needed to support latest updates on api resources.' ) . sendYes ( ) ;
621605 }
622606 switch ( completeSettings . updateOperation ) {
623- case 'Add another path' : {
624- // Register a one-shot auto-responder for the optional overlap warning.
625- // Same pattern as addRestApi: auto-respond 'y' to overlap via data handler so the single
626- // .wait('Choose a Lambda source') works correctly whether or not overlap occurs.
627- let overlapHandledUpdate = false ;
607+ case 'Add another path' :
628608 chain
629- . wait ( 'Provide a path' , ( ) => {
630- chain . getProcess ( ) ?. addOnDataHandler ( ( data : string ) => {
631- if ( ! overlapHandledUpdate && / o v e r l a p s w i t h / . test ( data ) ) {
632- overlapHandledUpdate = true ;
633- chain . getProcess ( ) ?. write ( 'y' ) ;
634- }
635- } ) ;
636- } )
609+ . wait ( 'Provide a path' )
637610 . sendLine ( completeSettings . newPath )
638611 . wait ( 'Choose a Lambda source' )
639612 . sendLine ( 'Use a Lambda function already added in the current Amplify project' ) ;
640613 // assumes only one function in the project. otherwise, need to update to handle function selection here
641614 break ;
642- }
643615 default :
644616 throw new Error ( `updateOperation ${ completeSettings . updateOperation } is not implemented` ) ;
645617 }
0 commit comments