Created
August 20, 2015 21:12
-
-
Save jed/4e8c30b587ba902b285d to your computer and use it in GitHub Desktop.
lambda tester
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {resolve} from "path" | |
let [pathname, args] = process.argv.slice(2) | |
if (!pathname) { | |
console.log("Usage: npm run test <path-to-script> <event-json>") | |
process.exit() | |
} | |
let path = resolve(process.cwd(), pathname) | |
let handler = require(path).handler | |
let success = data => console.log(JSON.stringify(data, null, 2)) | |
let failure = err => { throw err } | |
let done = (err, data) => err ? failure(err) : success(data) | |
handler(args, {success, failure, done}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment