@@ -31,8 +31,10 @@ process.argv.slice(2).forEach(function(arg) {
31
31
var util = require ( 'util' ) ;
32
32
var path = require ( 'path' ) ;
33
33
var child = require ( 'child_process' ) ;
34
- var argv = require ( 'optimist' ) .
34
+ var fs = require ( 'fs' ) ;
35
+ var optimist = require ( 'optimist' ) .
35
36
usage ( 'Usage: protractor [options] [configFile]\n' +
37
+ 'configFile defaults to protractor.conf.js\n' +
36
38
'The [options] object will override values from the config file.\n' +
37
39
'See the reference config for a full list of options.' ) .
38
40
describe ( 'help' , 'Print Protractor help menu' ) .
@@ -62,11 +64,9 @@ var argv = require('optimist').
62
64
if ( arg . _ . length > 1 ) {
63
65
throw 'Error: more than one config file specified' ;
64
66
}
65
- if ( process . argv . length < 3 || arg . help ) {
66
- throw '' ;
67
- }
68
- } ) .
69
- parse ( args ) ;
67
+ } ) ;
68
+
69
+ var argv = optimist . parse ( args ) ;
70
70
71
71
if ( argv . version ) {
72
72
util . puts ( 'Version ' + require ( path . join ( __dirname , '../package.json' ) ) . version ) ;
@@ -114,5 +114,17 @@ if (argv.excludes) {
114
114
argv . excludes = processFilePatterns_ ( argv . excludes ) ;
115
115
}
116
116
117
+ // Use default configuration, if it exists.
118
+ var configFile = argv . _ [ 0 ] ;
119
+ if ( ! configFile ) {
120
+ if ( fs . existsSync ( './protractor.conf.js' ) ) {
121
+ configFile = './protractor.conf.js' ;
122
+ }
123
+ }
124
+ if ( ! configFile && args . length < 3 ) {
125
+ optimist . showHelp ( ) ;
126
+ process . exit ( 1 ) ;
127
+ }
128
+
117
129
// Run the launcher
118
- require ( './launcher' ) . init ( argv . _ [ 0 ] , argv ) ;
130
+ require ( './launcher' ) . init ( configFile , argv ) ;
0 commit comments