Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Commit

Permalink
feat(cli): use protractor.conf.js as a default config file if none is…
Browse files Browse the repository at this point in the history
… passed

Closes #615
  • Loading branch information
juliemr committed Apr 15, 2014
1 parent fca9c5f commit 74761e8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
26 changes: 19 additions & 7 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ process.argv.slice(2).forEach(function(arg) {
var util = require('util');
var path = require('path');
var child = require('child_process');
var argv = require('optimist').
var fs = require('fs');
var optimist = require('optimist').
usage('Usage: protractor [options] [configFile]\n' +
'configFile defaults to protractor.conf.js\n' +
'The [options] object will override values from the config file.\n' +
'See the reference config for a full list of options.').
describe('help', 'Print Protractor help menu').
Expand Down Expand Up @@ -62,11 +64,9 @@ var argv = require('optimist').
if (arg._.length > 1) {
throw 'Error: more than one config file specified';
}
if (process.argv.length < 3 || arg.help) {
throw '';
}
}).
parse(args);
});

var argv = optimist.parse(args);

if (argv.version) {
util.puts('Version ' + require(path.join(__dirname, '../package.json')).version);
Expand Down Expand Up @@ -114,5 +114,17 @@ if (argv.excludes) {
argv.excludes = processFilePatterns_(argv.excludes);
}

// Use default configuration, if it exists.
var configFile = argv._[0];
if (!configFile) {
if (fs.existsSync('./protractor.conf.js')) {
configFile = './protractor.conf.js';
}
}
if (!configFile && args.length < 3) {
optimist.showHelp();
process.exit(1);
}

// Run the launcher
require('./launcher').init(argv._[0], argv);
require('./launcher').init(configFile, argv);
1 change: 1 addition & 0 deletions lib/launcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ var init = function(configFile, additionalConfig) {
launcherExitCode = 0;

var configParser = new ConfigParser();

if (configFile) {
configParser.addFileConfig(configFile);
}
Expand Down

0 comments on commit 74761e8

Please sign in to comment.