From 15fee6f9c214ce8c55827c6e4d4e63a00f8bc204 Mon Sep 17 00:00:00 2001 From: Christoph Kraemer Date: Tue, 16 Dec 2014 08:25:55 +0100 Subject: [PATCH] fix: Allow for karma.conf to be used correctly Now client config is only passed to karma if it's really defined in the grunt config. Closes #119 --- tasks/grunt-karma.js | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/tasks/grunt-karma.js b/tasks/grunt-karma.js index 4911d18..7918c11 100644 --- a/tasks/grunt-karma.js +++ b/tasks/grunt-karma.js @@ -36,18 +36,27 @@ module.exports = function(grunt) { // Allow for passing cli arguments to `client.args` using `--grep=x` var args = parseArgs(process.argv.slice(2)); - if (_.isArray(options.client.args)) { - options.client.args = options.client.args.concat(args); - } else { - options.client.args = args; + if (options.client && _.isArray(options.client.args)) { + args = options.client.args.concat(args); + } + + // If arguments are provided we pass them to karma + if (args.length > 0) { + if (!options.client) { + options.client = {}; + } + options.client.args = args; } - // Merge karma default options - _.defaults(options.client, { + //Only create client info if data is provided + if (options.client) { + // Merge karma default options + _.defaults(options.client, { args: [], useIframe: true, captureConsole: true - }); + }); + } var opts = _.cloneDeep(options); // Merge options onto data, with data taking precedence.