Skip to content

Commit a6aacf6

Browse files
abetomoDeviaVir
authored andcommitted
Clean deploy function (motdotla#220)
* Clean unnecessary `else` Deleted unnecessary `else` because it is` return` in `if` statement. This will reduce nesting. * Add a semicolon * Add comment * Fix commit
1 parent b02e16c commit a6aacf6

File tree

1 file changed

+28
-26
lines changed

1 file changed

+28
-26
lines changed

lib/main.js

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)