@@ -11,6 +11,16 @@ var glob = require('glob');
11
11
var args = process . argv . slice ( 2 ) ;
12
12
var configDir ;
13
13
14
+ var merge = function ( into , from ) {
15
+ for ( key in from ) {
16
+ if ( into [ key ] instanceof Object ) {
17
+ merge ( into [ key ] , from [ key ] ) ;
18
+ } else {
19
+ into [ key ] = from [ key ] ;
20
+ }
21
+ }
22
+ } ;
23
+
14
24
// Default configuration.
15
25
var config = {
16
26
seleniumServerJar : null ,
@@ -22,7 +32,6 @@ var config = {
22
32
} ,
23
33
rootElement : 'body' ,
24
34
jasmineNodeOpts : {
25
- specs : [ ] ,
26
35
isVerbose : false ,
27
36
showColors : true ,
28
37
includeStackTrace : true
@@ -70,6 +79,8 @@ var printVersion = function () {
70
79
} ;
71
80
72
81
var run = function ( ) {
82
+ util . puts ( util . inspect ( config ) ) ;
83
+ process . exit ( 0 ) ;
73
84
if ( config . jasmineNodeOpts . specFolders ) {
74
85
throw new Error ( 'Using config.jasmineNodeOpts.specFolders is deprecated ' +
75
86
'in Protractor 0.6.0. Please switch to config.specs.' ) ;
@@ -160,34 +171,70 @@ if (!args.length) {
160
171
util . puts ( 'USAGE: protractor configFile [options]' ) ;
161
172
util . puts ( 'Options:' ) ;
162
173
util . puts ( ' --version: Print Protractor version' ) ;
163
- util . puts ( ' --seleniumAddress: A running selenium address to use' ) ;
164
- util . puts ( ' --seleniumServerJar: Location of the standalone selenium server .jar file' ) ;
165
- util . puts ( ' --seleniumPort: Optional port for the standalone selenium server' ) ;
174
+ util . puts ( ' --seleniumAddress <string>: A running selenium address to use' ) ;
175
+ util . puts ( ' --seleniumServerJar <string>: Location of the standalone selenium server .jar file' ) ;
176
+ util . puts ( ' --seleniumPort <string>: Optional port for the standalone selenium server' ) ;
177
+ util . puts ( ' --baseUrl <string>: URL to prepend to all relative paths' ) ;
178
+ util . puts ( ' --rootElement <string>: Element housing ng-app, if not html or body' ) ;
179
+ util . puts ( ' --specs <list>: Comma separated list of files to test' ) ;
180
+ util . puts ( ' --[no]includeStackTrace: Print stack trace on error' ) ;
181
+ util . puts ( ' --verbose: Print full spec names' ) ;
166
182
167
183
process . exit ( 0 ) ;
168
184
}
169
185
186
+ var commandLineConfig = { capabilities : { } , jasmineNodeOpts : { } } ;
187
+
170
188
while ( args . length ) {
171
189
var arg = args . shift ( ) ;
172
190
switch ( arg ) {
173
191
case '--version' :
174
192
printVersion ( ) ;
175
193
break ;
176
194
case '--browser' :
177
- config . capabilities . browserName = args . shift ( ) ;
195
+ commandLineConfig . capabilities . browserName = args . shift ( ) ;
178
196
break ;
179
197
case '--seleniumAddress' :
180
- config . seleniumAddress = args . shift ( ) ;
198
+ commandLineConfig . seleniumAddress = args . shift ( ) ;
181
199
break ;
182
200
case '--seleniumServerJar' :
183
- config . seleniumServerJar = args . shift ( ) ;
201
+ commandLineConfig . seleniumServerJar = args . shift ( ) ;
184
202
break ;
185
203
case '--seleniumPort' :
186
- config . seleniumPort = args . shift ( ) ;
204
+ commandLineConfig . seleniumPort = args . shift ( ) ;
205
+ break ;
206
+ case '--sauceUser' :
207
+ commandLineConfig . sauceUser = args . shift ( ) ;
208
+ break ;
209
+ case '--sauceKey' :
210
+ commandLineConfig . sauceKey = args . shift ( ) ;
211
+ break ;
212
+ case '--baseUrl' :
213
+ commandLineConfig . baseUrl = args . shift ( ) ;
214
+ break ;
215
+ case '--rootElement' :
216
+ commandLineConfig . rootElement = args . shift ( ) ;
217
+ break ;
218
+ case '--specs' :
219
+ commandLineSpecs = args . shift ( ) . split ( ',' ) ;
220
+ commandLineSpecs . forEach ( function ( spec , index , arr ) {
221
+ arr [ index ] = path . resolve ( process . cwd ( ) , spec ) ;
222
+ } ) ;
223
+ commandLineConfig . specs = commandLineSpecs ;
224
+ break ;
225
+ case '--includeStackTrace' :
226
+ commandLineConfig . jasmineNodeOpts . includeStackTrace = true ;
227
+ break ;
228
+ case '--noincludeStackTrace' :
229
+ commandLineConfig . jasmineNodeOpts . includeStackTrace = false ;
230
+ break ;
231
+ case '--verbose' :
232
+ commandLineConfig . jasmineNodeOpts . isVerbose = true ;
187
233
break ;
188
234
default :
189
235
var configPath = path . resolve ( process . cwd ( ) , arg ) ;
190
- config = require ( configPath ) . config ;
236
+ merge ( config , require ( configPath ) . config ) ;
237
+ merge ( config , commandLineConfig ) ;
191
238
configDir = path . dirname ( configPath ) ;
192
239
break ;
193
240
}
0 commit comments