From 256b21cf8c744a200892e6b7f9172150b2f4fe8d Mon Sep 17 00:00:00 2001 From: JB Nizet Date: Sat, 21 Sep 2013 13:30:16 +0200 Subject: [PATCH] fix(cli): allow passing the config file before the options The cli usage says: > USAGE: protractor configFile [options] However, the options passed as argument are merged into the default configuration as soon as the configFile is met in the args parsing loop. This fix merges the options in the default configuration only after the loop, allowing to pass the options to the cli before or after, or around the config file. --- lib/cli.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/cli.js b/lib/cli.js index 825771564..684cf34b2 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -9,7 +9,7 @@ var SauceLabs = require('saucelabs'); var glob = require('glob'); var args = process.argv.slice(2); -var configDir; +var configDir, configPath; var merge = function(into, from) { for (key in from) { @@ -230,14 +230,15 @@ while(args.length) { commandLineConfig.jasmineNodeOpts.isVerbose = true; break; default: - var configPath = path.resolve(process.cwd(), arg); - merge(config, require(configPath).config); - merge (config, commandLineConfig); + configPath = path.resolve(process.cwd(), arg); configDir = path.dirname(configPath); break; } } +merge(config, require(configPath).config); +merge(config, commandLineConfig); + var sauceAccount; if (config.sauceUser && config.sauceKey) { sauceAccount = new SauceLabs({