From 65503ba768ce3609afb83e32b2e3c6d69e155695 Mon Sep 17 00:00:00 2001 From: chogan Date: Thu, 18 Feb 2016 10:51:05 -0600 Subject: [PATCH] Pass through all grunt options to protractor --- tasks/protractor_runner.js | 17 +++++++++++------ test/objectArgs_test.js | 5 ++--- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/tasks/protractor_runner.js b/tasks/protractor_runner.js index 368910b..65720b2 100644 --- a/tasks/protractor_runner.js +++ b/tasks/protractor_runner.js @@ -62,17 +62,17 @@ module.exports = function(grunt) { // Iterate over all supported arguments. strArgs.forEach(function(a) { - if (a in opts.args || grunt.option(a)) { - args.push('--'+a, grunt.option(a) || opts.args[a]); + if (a in opts.args) { + args.push('--'+a, opts.args[a]); } }); listArgs.forEach(function(a) { - if (a in opts.args || grunt.option(a)) { - args.push('--'+a, grunt.option(a) || opts.args[a].join(",")); + if (a in opts.args) { + args.push('--'+a, opts.args[a].join(",")); } }); boolArgs.forEach(function(a) { - if (a in opts.args || grunt.option(a)) { + if (a in opts.args) { args.push('--'+a); } }); @@ -110,9 +110,14 @@ module.exports = function(grunt) { args.push(prefix+"."+key, val); } } - })("--" + a, grunt.option(a) || opts.args[a], args); + })("--" + a, opts.args[a], args); }); + // Pass any remaining grunt options to protractor verbatim. + // + // This allows for adding to Object-flavored arguments, and for overriding + // any other flavor of arguments, via the command line. + args = args.concat(grunt.option.flags()); // Spawn protractor command var done = this.async(); diff --git a/test/objectArgs_test.js b/test/objectArgs_test.js index 18d1dac..c9c5905 100644 --- a/test/objectArgs_test.js +++ b/test/objectArgs_test.js @@ -2,14 +2,14 @@ var exec = require('child_process').execSync, runnerStdOut; exports.testCucumberOpts = function (test) { - var cmd = 'grunt protractor:testTargetConfigFile --cucumberOpts={\\"tags\\":\\"@quick\\"} --verbose', + var cmd = 'grunt protractor:testTargetConfigFile --cucumberOpts.tags=@quick --verbose', testDone = false; runnerStdOut = exec(cmd) if (typeof runnerStdOut === 'object'){ runnerStdOut = runnerStdOut.toString(); } - if (runnerStdOut.indexOf('Spawn node with arguments:') > -1 && runnerStdOut.indexOf('--cucumberOpts.tags @quick') > -1) { + if (runnerStdOut.indexOf('Spawn node with arguments:') > -1 && runnerStdOut.indexOf('--cucumberOpts.tags=@quick') > -1) { test.ok(true, 'CucumberOpts test passed!') test.done(); } else { @@ -17,4 +17,3 @@ exports.testCucumberOpts = function (test) { test.done(); } }; -