Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 9 additions & 19 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,39 +59,31 @@ 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

var callback = function (err, result) {
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 () {
var currentTime = new Date();
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) {
Expand Down Expand Up @@ -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'
Expand Down