Skip to content

Instantly share code, notes, and snippets.

@jed jed/test.js
Created Aug 20, 2015

Embed
What would you like to do?
lambda tester
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
You can’t perform that action at this time.