@@ -12,34 +12,38 @@ function create_file(file_path, content) {
12
12
}
13
13
14
14
function 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" ]
19
18
}
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" ] != "" ) {
21
23
//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" ] ) ;
24
26
if ( stats . isFile ( ) ) {
25
- make_file ( args . _ [ 1 ] , content )
27
+ create_file ( args [ "config-file-name" ] , content )
26
28
}
27
29
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 )
29
31
}
30
32
}
31
33
else {
32
- filename = path . basename ( args . _ [ 1 ] )
34
+ filename = path . basename ( args [ "config-file-name" ] )
33
35
var re = new RegExp ( ".+\\..+" ) ;
34
36
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 )
41
42
}
42
43
}
44
+ } else {
45
+ console . log ( "Picking the default config file name " , constants . LT_CONFIG_NAME )
46
+ create_file ( constants . LT_CONFIG_NAME , content )
43
47
}
44
48
} ;
45
49
@@ -59,13 +63,17 @@ function create_custom_support_file(args){
59
63
console . log ( "Error while copying custom support file" , err ) ;
60
64
}
61
65
else {
62
- console . log ( "Successfully saved custom support file at - " , pathToNewDestination ) ;
66
+ console . log ( "Saved at " , pathToNewDestination ) ;
63
67
}
64
68
} ) ;
65
69
}
66
70
67
71
module . exports = function ( args ) {
68
72
create_ltconfig_file ( args ) ;
69
73
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
+ }
71
79
} ;
0 commit comments