Skip to content

Commit cf046db

Browse files
committed
add -j --eventFile parameter to the run command for testing alternate events
1 parent 0eb2aab commit cf046db

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

bin/node-lambda

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ var AWS_TIMEOUT = process.env.AWS_TIMEOUT || 60;
2222
var AWS_DESCRIPTION = process.env.AWS_DESCRIPTION || '';
2323
var AWS_RUNTIME = process.env.AWS_RUNTIME || 'nodejs';
2424
var AWS_FUNCTION_VERSION = process.env.AWS_FUNCTION_VERSION || '';
25+
var EVENT_FILE = process.env.EVENT_FILE || 'event.json';
2526

2627
program
2728
.version(lambda.version)
@@ -53,6 +54,7 @@ program
5354
.command('run')
5455
.description('Run your Amazon Lambda application locally')
5556
.option('-h, --handler [' + AWS_HANDLER + ']', 'Lambda Handler {index.handler}', AWS_HANDLER)
57+
.option('-j --eventFile [' + EVENT_FILE + ']', 'Event JSON File', EVENT_FILE)
5658
.action(function (prg) {
5759
lambda.run(prg);
5860
});

lib/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Lambda.prototype.run = function (program) {
4343
var handlername = splitHandler[1];
4444

4545
var handler = require(process.cwd() + '/' + filename)[handlername];
46-
var event = require(process.cwd() + '/event.json');
46+
var event = require(process.cwd() + '/' + program.eventFile);
4747

4848
this._runHandler(handler, event);
4949
};

0 commit comments

Comments
 (0)