11'use strict' ;
22
3+ var fs = require ( 'fs-plus' ) ;
34var path = require ( 'path' ) ;
45var program = require ( 'commander' ) ;
56var pjson = require ( './package.json' ) ;
@@ -10,21 +11,34 @@ function collectPaths(value, paths) {
1011 return paths ;
1112}
1213
14+ var config = {
15+ "step_def_dir" : "./step-definitions" ,
16+ "page_obj_dir" : "./page-objects" ,
17+ "shared_obj_dir" : "./shared-objects" ,
18+ "reports_dir" : "./reports" ,
19+ "default_browser" : "chrome" ,
20+ "timeout" : 10000
21+ } ;
22+ var configFileName = path . resolve ( process . cwd ( ) , 'selenium-cucumber-js.json' ) ;
23+ if ( fs . isFileSync ( configFileName ) ) {
24+ config = Object . assign ( config , require ( configFileName ) ) ;
25+ }
26+
1327program
14- . version ( pjson . version )
15- . description ( pjson . description )
16- . option ( '-s, --steps <path>' , 'path to step definitions. defaults to ./step-definitions' , './step-definitions' )
17- . option ( '-p, --pageObjects <path>' , 'path to page objects. defaults to ./page-objects' , './page-objects' )
18- . option ( '-o, --sharedObjects [paths]' , 'path to shared objects (repeatable). defaults to ./shared-objects' , collectPaths , [ './shared-objects' ] )
19- . option ( '-b, --browser <path>' , 'name of browser to use. defaults to chrome' , / ^ ( c h r o m e | f i r e f o x | p h a n t o m j s ) $ / i , 'chrome' )
20- . option ( '-r, --reports <path>' , 'output path to save reports. defaults to ./reports' , './reports' )
21- . option ( '-d, --disableLaunchReport [optional]' , 'Disables the auto opening the browser with test report' )
22- . option ( '-j, --junit <path>' , 'output path to save junit-report.xml defaults to ./reports' )
23- . option ( '-t, --tags <tagName>' , 'name of tag to run' )
24- . option ( '-f, --featureFile <path>' , 'a specific feature file to run' )
25- . option ( '-x, --timeOut <n>' , 'steps definition timeout in milliseconds. defaults to 10 seconds' , parseInt )
26- . option ( '-n, --noScreenshot [optional]' , 'disable auto capturing of screenshots when an error is encountered' )
27- . parse ( process . argv ) ;
28+ . version ( pjson . version )
29+ . description ( pjson . description )
30+ . option ( '-s, --steps <path>' , 'path to step definitions. defaults to ' + config . step_def_dir , config . step_def_dir )
31+ . option ( '-p, --pageObjects <path>' , 'path to page objects. defaults to ' + config . page_obj_dir , config . page_obj_dir )
32+ . option ( '-o, --sharedObjects [paths]' , 'path to shared objects (repeatable). defaults to ' + config . shared_obj_dir , collectPaths , [ config . shared_obj_dir ] )
33+ . option ( '-b, --browser <path>' , 'name of browser to use. defaults to ' + config . default_browser , config . default_browser )
34+ . option ( '-r, --reports <path>' , 'output path to save reports. defaults to ' + config . reports_dir , config . reports_dir )
35+ . option ( '-d, --disableLaunchReport [optional]' , 'Disables the auto opening the browser with test report' )
36+ . option ( '-j, --junit <path>' , 'output path to save junit-report.xml defaults to ' + config . reports_dir )
37+ . option ( '-t, --tags <tagName>' , 'name of tag to run' )
38+ . option ( '-f, --featureFile <path>' , 'a specific feature file to run' )
39+ . option ( '-x, --timeOut <n>' , 'steps definition timeout in milliseconds. defaults to ' + config . timeout , parseInt , config . timeout )
40+ . option ( '-n, --noScreenshot [optional]' , 'disable auto capturing of screenshots when an error is encountered' )
41+ . parse ( process . argv ) ;
2842
2943program . on ( '--help' , function ( ) {
3044 console . log ( ' For more details please visit https://github.com/john-doherty/selenium-cucumber-js#readme\n' ) ;
0 commit comments