diff --git a/lib/main.js b/lib/main.js index 61fc25e5..1e1eae9e 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 @@ -67,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 () { @@ -81,17 +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) { @@ -255,11 +247,9 @@ Lambda.prototype._postInstallScript = function (program, codeDirectory, callback callback(null); } }); - }; Lambda.prototype._zip = function (program, codeDirectory, callback) { - var options = { type: 'nodebuffer', compression: 'DEFLATE'