@@ -597,6 +597,7 @@ Lambda.prototype.deploy = function (program) {
597597 'FunctionName' : params . FunctionName
598598 } , function ( err ) {
599599 if ( err ) {
600+ // Function does not exist
600601 return _this . _uploadNew ( lambda , params , function ( err , results ) {
601602 if ( err ) {
602603 throw err ;
@@ -609,34 +610,35 @@ Lambda.prototype.deploy = function (program) {
609610 cb ( null , results ) ;
610611 } ) ;
611612 } ) ;
612- } else {
613- _this . _listEventSourceMappings ( lambda , {
614- 'FunctionName' : params . FunctionName
615- } , function ( err , existingEventSourceList ) {
616- if ( err ) {
617- throw err ;
613+ }
614+
615+ // Function exists
616+ _this . _listEventSourceMappings ( lambda , {
617+ 'FunctionName' : params . FunctionName
618+ } , function ( err , existingEventSourceList ) {
619+ if ( err ) {
620+ throw err ;
621+ }
622+ return async . parallel ( [
623+ function ( _callback ) {
624+ _this . _uploadExisting ( lambda , params , function ( err , results ) {
625+ if ( err ) {
626+ throw err ;
627+ }
628+ console . log ( '=> Zip file(s) done uploading. Results follow: ' ) ;
629+ console . log ( results ) ;
630+ _callback ( err , results ) ;
631+ } ) ;
632+ } ,
633+ function ( _callback ) {
634+ _this . _updateEventSources ( lambda , params . FunctionName , existingEventSourceList , eventSourceList , function ( err , results ) {
635+ _callback ( err , results ) ;
636+ } ) ;
618637 }
619- return async . parallel ( [
620- function ( _callback ) {
621- _this . _uploadExisting ( lambda , params , function ( err , results ) {
622- if ( err ) {
623- throw err ;
624- }
625- console . log ( '=> Zip file(s) done uploading. Results follow: ' ) ;
626- console . log ( results ) ;
627- _callback ( err , results ) ;
628- } )
629- } ,
630- function ( _callback ) {
631- _this . _updateEventSources ( lambda , params . FunctionName , existingEventSourceList , eventSourceList , function ( err , results ) {
632- _callback ( err , results )
633- } )
634- }
635- ] , function ( err , results ) {
636- cb ( err , results ) ;
637- } ) ;
638+ ] , function ( err , results ) {
639+ cb ( err , results ) ;
638640 } ) ;
639- }
641+ } ) ;
640642 } ) ;
641643 } , function ( err , results ) {
642644 if ( err ) {
0 commit comments