Permalink
Browse files

Fast execution script

Run your lambdas from a single CLI command
  • Loading branch information...
rricard committed Nov 22, 2015
1 parent 28f0108 commit a41308a0d85e04d5b76d6513e8fe98088e63df51
Showing with 35 additions and 0 deletions.
  1. +33 −0 bin/run.js
  2. +2 −0 package.json
@@ -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);
@@ -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"

0 comments on commit a41308a

Please sign in to comment.