Skip to content

Commit

Permalink
Fast execution script
Browse files Browse the repository at this point in the history
Run your lambdas from a single CLI command
  • Loading branch information
rricard committed Nov 22, 2015
1 parent 28f0108 commit a41308a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
33 changes: 33 additions & 0 deletions bin/run.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const args = process.argv;
const requiredLambda = args[2].split(".");
const lambdaModule = require(`../dist/${requiredLambda[0]}.js`);
const lambda = lambdaModule[requiredLambda[1]];
const options = JSON.parse(args[3]);

function succeed(result) {
console.log(result);
process.exit(0);
}

function fail(error) {
console.error(error);
process.exit(1);
}

const context = {
succeed: succeed,
fail: fail,
done: (err, res) => err ? fail(err) : succeed(res),
getRemainingTimeInMillis: () => Infinity,
functionName: "fakeLambda",
functionVersion: "0",
invokedFunctionArn: "arn:aws:lambda:fake-region:fake-acc:function:fakeLambda",
memoryLimitInMB: Infinity,
awsRequestId: "fakeRequest",
logGroupName: "fakeGroup",
logStreamName: "fakeStream",
identity: null,
clientContext: null
};

lambda(options, context);
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
"main": "index.js",
"scripts": {
"start": "webpack --watch",
"prepublish": "webpack",
"test": "exit 1"
},
"bin": "./bin/run.js",
"repository": {
"type": "git",
"url": "git+https://github.com/rricard/lambda-es6-example.git"
Expand Down

0 comments on commit a41308a

Please sign in to comment.