From ad2a39ead2a74e0b9102c587cf798924dc116ddb Mon Sep 17 00:00:00 2001 From: Jonathan Foote Date: Wed, 20 May 2015 11:54:13 -0400 Subject: [PATCH] Fully mock up the context object to work with succeed and fail --- tasks/lambda_invoke.js | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/tasks/lambda_invoke.js b/tasks/lambda_invoke.js index aee9426..18ab6a3 100644 --- a/tasks/lambda_invoke.js +++ b/tasks/lambda_invoke.js @@ -30,14 +30,31 @@ module.exports = function (grunt) { var done = this.async(); var context = { - done: function (status, message) { - var success = status === null; + done: function (error, result) { + if (error === null) { + this.succeed(result); + } else { + this.fail(error); + } + }, + succeed: function (result) { grunt.log.writeln(""); - grunt.log.writeln("Message"); - grunt.log.writeln("-------"); - grunt.log.writeln(message); - done(success); - } + grunt.log.writeln("Success! Message:"); + grunt.log.writeln("------------------"); + grunt.log.writeln(result); + done(true); + }, + fail: function (error) { + grunt.log.writeln(""); + grunt.log.writeln("Failure! Message:"); + grunt.log.writeln("------------------"); + grunt.log.writeln(error); + done(false); + }, + awsRequestId: 'LAMBDA_INVOKE', + logStreamName: 'LAMBDA_INVOKE', + clientContext: null, + identity: null }; var lambda = require(path.resolve(options.file_name));