diff --git a/.gitignore b/.gitignore index b785247..7bdfc1b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules npm-debug.log tmp +.idea \ No newline at end of file diff --git a/README.md b/README.md index cec1a5b..8a87687 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,12 @@ Default value: `event.json` Name of the .json file containing your test event relative to your Gruntfile. +##### options.env_variables +Type: `Object` +Default value: `null` + +A object that will be added as environment variables (process.env) when running task. + #### Usage Examples ##### Default Options diff --git a/utils/invoke_task.js b/utils/invoke_task.js index a9db0b9..d8ae187 100644 --- a/utils/invoke_task.js +++ b/utils/invoke_task.js @@ -27,7 +27,8 @@ invokeTask.getHandler = function (grunt) { 'file_name': 'index.js', 'event': 'event.json', 'client_context': 'client_context.json', - 'identity': 'identity.json' + 'identity': 'identity.json', + 'env_variables': null }); grunt.log.writeln(""); @@ -36,6 +37,14 @@ invokeTask.getHandler = function (grunt) { var clientContext = null; + if(options.env_variables) { + for(var variable in options.env_variables) { + if(options.env_variables.hasOwnProperty(variable)) { + process.env[variable] = options.env_variables[variable]; + } + } + } + //since clientContext should be optional, skip if doesn't exist try { clientContext = JSON.parse(fs.readFileSync(path.resolve(options.client_context), "utf8"));