From be4e365cf9876421e8ba23b08fefbf4afef0340a Mon Sep 17 00:00:00 2001 From: abetomo Date: Thu, 6 Apr 2017 19:07:41 +0900 Subject: [PATCH 1/4] Clean unnecessary `else` Deleted unnecessary `else` because it is` return` in `if` statement. This will reduce nesting. --- lib/main.js | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/lib/main.js b/lib/main.js index 053085c3..feba00cd 100644 --- a/lib/main.js +++ b/lib/main.js @@ -609,34 +609,34 @@ Lambda.prototype.deploy = function (program) { cb(null, results); }); }); - } else { - _this._listEventSourceMappings(lambda, { - 'FunctionName': params.FunctionName - }, function(err, existingEventSourceList) { - if (err) { - throw err; + } + + _this._listEventSourceMappings(lambda, { + 'FunctionName': params.FunctionName + }, function(err, existingEventSourceList) { + if (err) { + throw err; + } + return async.parallel([ + function(_callback) { + _this._uploadExisting(lambda, params, function(err, results) { + if (err) { + throw err; + } + console.log('=> Zip file(s) done uploading. Results follow: '); + console.log(results); + _callback(err, results); + }) + }, + function(_callback) { + _this._updateEventSources(lambda, params.FunctionName, existingEventSourceList, eventSourceList, function(err, results) { + _callback(err, results) + }) } - return async.parallel([ - function(_callback) { - _this._uploadExisting(lambda, params, function(err, results) { - if (err) { - throw err; - } - console.log('=> Zip file(s) done uploading. Results follow: '); - console.log(results); - _callback(err, results); - }) - }, - function(_callback) { - _this._updateEventSources(lambda, params.FunctionName, existingEventSourceList, eventSourceList, function(err, results) { - _callback(err, results) - }) - } - ], function(err, results) { - cb(err, results); - }); + ], function(err, results) { + cb(err, results); }); - } + }); }); }, function (err, results) { if (err) { From 9f0a71a63803d17359ccc149bc1ea78109b53d65 Mon Sep 17 00:00:00 2001 From: abetomo Date: Thu, 6 Apr 2017 19:16:02 +0900 Subject: [PATCH 2/4] Add a semicolon --- lib/main.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index feba00cd..cc664d6f 100644 --- a/lib/main.js +++ b/lib/main.js @@ -626,12 +626,12 @@ Lambda.prototype.deploy = function (program) { console.log('=> Zip file(s) done uploading. Results follow: '); console.log(results); _callback(err, results); - }) + }); }, function(_callback) { _this._updateEventSources(lambda, params.FunctionName, existingEventSourceList, eventSourceList, function(err, results) { - _callback(err, results) - }) + _callback(err, results); + }); } ], function(err, results) { cb(err, results); From 75d8d1ec81164bba0e9442bcf529be101e7d89b7 Mon Sep 17 00:00:00 2001 From: abetomo Date: Thu, 6 Apr 2017 19:19:05 +0900 Subject: [PATCH 3/4] Add comment --- lib/main.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/main.js b/lib/main.js index cc664d6f..320776eb 100644 --- a/lib/main.js +++ b/lib/main.js @@ -597,6 +597,7 @@ Lambda.prototype.deploy = function (program) { 'FunctionName': params.FunctionName }, function (err) { if (err) { + // Function not exsits return _this._uploadNew(lambda, params, function(err, results) { if (err) { throw err; @@ -611,6 +612,7 @@ Lambda.prototype.deploy = function (program) { }); } + // Function exists _this._listEventSourceMappings(lambda, { 'FunctionName': params.FunctionName }, function(err, existingEventSourceList) { From 32c6b67bb56c152fe9a964ecdb550c739047a2f4 Mon Sep 17 00:00:00 2001 From: abetomo Date: Thu, 6 Apr 2017 11:39:29 +0000 Subject: [PATCH 4/4] Fix commit --- lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/main.js b/lib/main.js index 320776eb..3d8017e9 100644 --- a/lib/main.js +++ b/lib/main.js @@ -597,7 +597,7 @@ Lambda.prototype.deploy = function (program) { 'FunctionName': params.FunctionName }, function (err) { if (err) { - // Function not exsits + // Function does not exist return _this._uploadNew(lambda, params, function(err, results) { if (err) { throw err;