From 382f1ad8663df97b9a38f3d1d1c6440a1230143a Mon Sep 17 00:00:00 2001 From: abetomo Date: Fri, 14 Apr 2017 11:47:34 +0900 Subject: [PATCH 1/3] Remove unnecessary line feeds Unified code format --- lib/main.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/main.js b/lib/main.js index 61fc25e5..4e70abf3 100644 --- a/lib/main.js +++ b/lib/main.js @@ -59,7 +59,6 @@ Lambda.prototype.run = function (program) { }; Lambda.prototype._runHandler = function (handler, event, program, context) { - var startTime = new Date(); var timeout = Math.min(program.timeout, 300) * 1000; // convert the timeout into milliseconds @@ -91,7 +90,6 @@ Lambda.prototype._runHandler = function (handler, event, program, context) { default: console.error("Runtime [" + runtime + "] is not supported."); } - }; Lambda.prototype._params = function (program, buffer) { @@ -255,11 +253,9 @@ Lambda.prototype._postInstallScript = function (program, codeDirectory, callback callback(null); } }); - }; Lambda.prototype._zip = function (program, codeDirectory, callback) { - var options = { type: 'nodebuffer', compression: 'DEFLATE' From 1b6ff81c0931ef6b53473984e4737e840ca521a9 Mon Sep 17 00:00:00 2001 From: abetomo Date: Fri, 14 Apr 2017 11:55:13 +0900 Subject: [PATCH 2/3] Clean unnecessary `else` Because it is `process.exit (-1);` in case of error --- lib/main.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 4e70abf3..199036e8 100644 --- a/lib/main.js +++ b/lib/main.js @@ -66,13 +66,12 @@ Lambda.prototype._runHandler = function (handler, event, program, context) { if (err) { console.log('Error: ' + err); process.exit(-1); - } else { - console.log('Success:'); - if (result) { - console.log(JSON.stringify(result)); - } - process.exit(0); } + console.log('Success:'); + if (result) { + console.log(JSON.stringify(result)); + } + process.exit(0); }; context.getRemainingTimeInMillis = function () { From 4eb9d61925d8fe413158e9532480197390ca4eb3 Mon Sep 17 00:00:00 2001 From: abetomo Date: Fri, 14 Apr 2017 12:58:19 +0900 Subject: [PATCH 3/3] Fix switch statement of `program.runtime` --- lib/main.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/lib/main.js b/lib/main.js index 199036e8..1e1eae9e 100644 --- a/lib/main.js +++ b/lib/main.js @@ -79,16 +79,11 @@ Lambda.prototype._runHandler = function (handler, event, program, context) { return timeout - (currentTime - startTime); }; - switch(program.runtime) { - case "nodejs4.3": - handler(event, context, callback); - break; - case "nodejs6.10": - handler(event, context, callback); - break; - default: - console.error("Runtime [" + runtime + "] is not supported."); + if (['nodejs4.3', 'nodejs6.10'].indexOf(program.runtime) == -1) { + console.error("Runtime [" + program.runtime + "] is not supported."); + process.exit(-2); } + handler(event, context, callback); }; Lambda.prototype._params = function (program, buffer) {