From 4e50c28afb48bfcde2ffcc95c18583f0b5ef0a64 Mon Sep 17 00:00:00 2001 From: Paul Bierly Date: Sun, 6 Dec 2015 02:15:31 -0600 Subject: [PATCH 1/3] Changed reference to 'this' to 'context' in lambda_invoke. Issue was that 'this' was already the grunt 'this' object and in these 2 references we needed 'this' to actually be the 'context' object. Just forced those 2 instances to reference 'context' instead of 'this'. --- tasks/lambda_invoke.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks/lambda_invoke.js b/tasks/lambda_invoke.js index 18ab6a3..ea1aa1e 100644 --- a/tasks/lambda_invoke.js +++ b/tasks/lambda_invoke.js @@ -32,9 +32,9 @@ module.exports = function (grunt) { var context = { done: function (error, result) { if (error === null) { - this.succeed(result); + context.succeed(result); } else { - this.fail(error); + context.fail(error); } }, succeed: function (result) { From 5d785a1b271af65670a0ca6b1eec81bdfa22fef2 Mon Sep 17 00:00:00 2001 From: Paul Bierly Date: Sun, 6 Dec 2015 03:11:36 -0600 Subject: [PATCH 2/3] added check to see if response for invoke succeed or failed is an object or string and console log a stringified version of an object if it is one. --- tasks/lambda_invoke.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tasks/lambda_invoke.js b/tasks/lambda_invoke.js index ea1aa1e..3094e9e 100644 --- a/tasks/lambda_invoke.js +++ b/tasks/lambda_invoke.js @@ -40,15 +40,17 @@ module.exports = function (grunt) { succeed: function (result) { grunt.log.writeln(""); grunt.log.writeln("Success! Message:"); - grunt.log.writeln("------------------"); - grunt.log.writeln(result); + grunt.log.writeln("------------------");' + var msg = (typeof(result) === 'object' ? JSON.stringify(result) : result); + grunt.log.writeln(msg); done(true); }, fail: function (error) { grunt.log.writeln(""); grunt.log.writeln("Failure! Message:"); grunt.log.writeln("------------------"); - grunt.log.writeln(error); + var msg = (typeof(result) === 'object' ? JSON.stringify(result) : result); + grunt.log.writeln(msg); done(false); }, awsRequestId: 'LAMBDA_INVOKE', From f544e425d906196611b3068b9e07ef2c13e1f121 Mon Sep 17 00:00:00 2001 From: Paul Bierly Date: Thu, 10 Dec 2015 00:09:38 -0600 Subject: [PATCH 3/3] corrected duplicated variable. added cleaner exit messages other than just getting 'undefined'. made error and result both optional for context.done --- tasks/lambda_invoke.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tasks/lambda_invoke.js b/tasks/lambda_invoke.js index 3094e9e..dd29578 100644 --- a/tasks/lambda_invoke.js +++ b/tasks/lambda_invoke.js @@ -31,7 +31,7 @@ module.exports = function (grunt) { var context = { done: function (error, result) { - if (error === null) { + if (error === null || typeof(error) === 'undefined') { context.succeed(result); } else { context.fail(error); @@ -40,17 +40,17 @@ module.exports = function (grunt) { succeed: function (result) { grunt.log.writeln(""); grunt.log.writeln("Success! Message:"); - grunt.log.writeln("------------------");' - var msg = (typeof(result) === 'object' ? JSON.stringify(result) : result); - grunt.log.writeln(msg); + grunt.log.writeln("------------------"); + var msg = (typeof(result) === 'object') ? JSON.stringify(result) : result; + grunt.log.writeln((typeof(result) !== 'undefined') ? msg : "Successful!"); done(true); }, fail: function (error) { grunt.log.writeln(""); grunt.log.writeln("Failure! Message:"); grunt.log.writeln("------------------"); - var msg = (typeof(result) === 'object' ? JSON.stringify(result) : result); - grunt.log.writeln(msg); + var msg = (typeof(error) === 'object') ? JSON.stringify(error) : error; + grunt.log.writeln((typeof(error) !== 'undefined') ? msg : "Error not provided."); done(false); }, awsRequestId: 'LAMBDA_INVOKE',