@@ -566,13 +566,15 @@ Lambda.prototype._buildAndArchive = function (program) {
566566 } )
567567}
568568
569- Lambda . prototype . _listEventSourceMappings = function ( lambda , params , cb ) {
570- return lambda . listEventSourceMappings ( params , function ( err , data ) {
571- var eventSourceMappings = [ ]
572- if ( ! err && data && data . EventSourceMappings ) {
573- eventSourceMappings = data . EventSourceMappings
574- }
575- return cb ( err , eventSourceMappings )
569+ Lambda . prototype . _listEventSourceMappings = ( lambda , params ) => {
570+ return new Promise ( ( resolve , reject ) => {
571+ lambda . listEventSourceMappings ( params , ( err , data ) => {
572+ if ( err ) return reject ( err )
573+ if ( data && data . EventSourceMappings ) {
574+ return resolve ( data . EventSourceMappings )
575+ }
576+ return resolve ( [ ] )
577+ } )
576578 } )
577579}
578580
@@ -764,11 +766,9 @@ Lambda.prototype._deployToRegion = function (program, params, region) {
764766 'FunctionName' : params . FunctionName
765767 } ) . promise ( ) . then ( ( ) => {
766768 // Function exists
767- _this . _listEventSourceMappings ( lambda , {
769+ return _this . _listEventSourceMappings ( lambda , {
768770 'FunctionName' : params . FunctionName
769- } , ( err , existingEventSourceList ) => {
770- if ( err ) return reject ( err )
771-
771+ } ) . then ( ( existingEventSourceList ) => {
772772 return Promise . all ( [
773773 _this . _uploadExisting ( lambda , params ) . then ( ( results ) => {
774774 console . log ( '=> Zip file(s) done uploading. Results follow: ' )
@@ -787,9 +787,9 @@ Lambda.prototype._deployToRegion = function (program, params, region) {
787787 )
788788 ] ) . then ( ( results ) => {
789789 resolve ( results )
790- } ) . catch ( ( err ) => {
791- reject ( err )
792790 } )
791+ } ) . catch ( ( err ) => {
792+ reject ( err )
793793 } )
794794 } ) . catch ( ( ) => {
795795 // Function does not exist
@@ -811,8 +811,6 @@ Lambda.prototype._deployToRegion = function (program, params, region) {
811811 )
812812 ] ) . then ( ( results ) => {
813813 resolve ( results )
814- } ) . catch ( ( err ) => {
815- reject ( err )
816814 } )
817815 } ) . catch ( ( err ) => {
818816 reject ( err )
0 commit comments