@@ -12,34 +12,38 @@ function create_file(file_path, content) {
1212}
1313
1414function create_ltconfig_file ( args ) {
15- let config = require ( './utils/default_config.js' )
16- let content = JSON . stringify ( config , null , 3 ) ;
17- if ( args . _ . length == 1 ) {
18- create_file ( constants . LT_CONFIG_NAME , content )
15+ let cv = 9.6
16+ if ( "cv" in args ) {
17+ cv = args [ "cv" ]
1918 }
20- else if ( args . _ . length > 1 ) {
19+ let config = parseInt ( cv ) >= 10 ?require ( './utils/default_config_10.js' ) :require ( './utils/default_config_9.js' )
20+ config . run_settings . npm_dependencies . cypress = cv . toString ( )
21+ let content = JSON . stringify ( config , null , 3 ) ;
22+ if ( "config-file-name" in args && args [ "config-file-name" ] != "" ) {
2123 //check if file or directory exists
22- if ( fs . existsSync ( args . _ [ 1 ] ) ) {
23- let stats = fs . statSync ( args . _ [ 1 ] ) ;
24+ if ( fs . existsSync ( args [ "config-file-name" ] ) ) {
25+ let stats = fs . statSync ( args [ "config-file-name" ] ) ;
2426 if ( stats . isFile ( ) ) {
25- make_file ( args . _ [ 1 ] , content )
27+ create_file ( args [ "config-file-name" ] , content )
2628 }
2729 else {
28- create_file ( path . join ( args . _ [ 1 ] , constants . LT_CONFIG_NAME ) , content )
30+ create_file ( path . join ( args [ "config-file-name" ] , constants . LT_CONFIG_NAME ) , content )
2931 }
3032 }
3133 else {
32- filename = path . basename ( args . _ [ 1 ] )
34+ filename = path . basename ( args [ "config-file-name" ] )
3335 var re = new RegExp ( ".+\\..+" ) ;
3436 if ( re . test ( filename ) ) {
35- fs . mkdirSync ( path . dirname ( args . _ [ 1 ] ) , { recursive : true } ) ;
36- create_file ( args . _ [ 1 ] , content )
37- }
38- else {
39- fs . mkdirSync ( args . _ [ 1 ] , { recursive : true } ) ;
40- create_file ( path . join ( args . _ [ 1 ] , constants . LT_CONFIG_NAME ) , content )
37+ fs . mkdirSync ( path . dirname ( args [ "config-file-name" ] ) , { recursive : true } ) ;
38+ create_file ( args [ "config-file-name" ] , content )
39+ } else {
40+ fs . mkdirSync ( args [ "config-file-name" ] , { recursive : true } ) ;
41+ create_file ( path . join ( args [ "config-file-name" ] , constants . LT_CONFIG_NAME ) , content )
4142 }
4243 }
44+ } else {
45+ console . log ( "Picking the default config file name " , constants . LT_CONFIG_NAME )
46+ create_file ( constants . LT_CONFIG_NAME , content )
4347 }
4448} ;
4549
@@ -59,13 +63,17 @@ function create_custom_support_file(args){
5963 console . log ( "Error while copying custom support file" , err ) ;
6064 }
6165 else {
62- console . log ( "Successfully saved custom support file at - " , pathToNewDestination ) ;
66+ console . log ( "Saved at " , pathToNewDestination ) ;
6367 }
6468 } ) ;
6569}
6670
6771module . exports = function ( args ) {
6872 create_ltconfig_file ( args ) ;
6973 create_base_reporter_config_file ( args ) ;
70- create_custom_support_file ( args ) ;
74+ if ( "cv" in args ) {
75+ if ( parseInt ( args [ "cv" ] ) >= 10 ) {
76+ create_custom_support_file ( args ) ;
77+ }
78+ }
7179} ;
0 commit comments