@@ -67,10 +67,14 @@ const caps = (bsConfig, zip) => {
67
67
obj . callbackURL = bsConfig . run_settings . callback_url ;
68
68
obj . projectNotifyURL = bsConfig . run_settings . project_notify_URL ;
69
69
obj . parallels = bsConfig . run_settings . parallels ;
70
+
71
+ if ( bsConfig . run_settings . cypress_config_filename ) {
72
+ obj . cypress_config_filename = bsConfig . run_settings . cypress_config_filename ;
73
+ }
70
74
}
71
75
72
76
if ( obj . parallels === Constants . constants . DEFAULT_PARALLEL_MESSAGE ) obj . parallels = undefined
73
-
77
+
74
78
if ( obj . project ) logger . log ( `Project name is: ${ obj . project } ` ) ;
75
79
76
80
if ( obj . customBuildName ) logger . log ( `Build name is: ${ obj . customBuildName } ` ) ;
@@ -106,18 +110,24 @@ const validate = (bsConfig, args) => {
106
110
// if parallels specified via arguments validate only arguments
107
111
if ( ! Utils . isUndefined ( args ) && ! Utils . isUndefined ( args . parallels ) && ! Utils . isParallelValid ( args . parallels ) ) reject ( Constants . validationMessages . INVALID_PARALLELS_CONFIGURATION ) ;
108
112
109
- if ( ! fs . existsSync ( path . join ( bsConfig . run_settings . cypress_proj_dir , 'cypress.json' ) ) ) reject ( Constants . validationMessages . CYPRESS_JSON_NOT_FOUND + bsConfig . run_settings . cypress_proj_dir ) ;
113
+ // validate if config file provided exists or not when cypress_config_file provided
114
+ // validate existing cypress_proj_dir key otherwise.
115
+ let cypressConfigFilePath = bsConfig . run_settings . cypressConfigFilePath ;
116
+
117
+ if ( ! fs . existsSync ( cypressConfigFilePath ) && bsConfig . run_settings . cypress_config_filename !== 'false' ) reject ( Constants . validationMessages . CYPRESS_JSON_NOT_FOUND + cypressConfigFilePath ) ;
110
118
111
119
try {
112
- let cypressJson = fs . readFileSync ( path . join ( bsConfig . run_settings . cypress_proj_dir , 'cypress.json' ) ) ;
113
- cypressJson = JSON . parse ( cypressJson ) ;
114
- // Cypress Json Base Url & Local true check
115
- if ( ! Utils . isUndefined ( cypressJson . baseUrl ) && cypressJson . baseUrl . includes ( "localhost" ) && ! Utils . getLocalFlag ( bsConfig . connection_settings ) ) reject ( Constants . validationMessages . LOCAL_NOT_SET ) ;
116
-
117
- // Detect if the user is not using the right directory structure, and throw an error
118
- if ( ! Utils . isUndefined ( cypressJson . integrationFolder ) && ! Utils . isCypressProjDirValid ( bsConfig . run_settings . cypress_proj_dir , cypressJson . integrationFolder ) ) reject ( Constants . validationMessages . INCORRECT_DIRECTORY_STRUCTURE ) ;
119
-
120
- } catch ( error ) {
120
+ if ( bsConfig . run_settings . cypress_config_filename !== 'false' ) {
121
+ let cypressJsonContent = fs . readFileSync ( cypressConfigFilePath ) ;
122
+ cypressJson = JSON . parse ( cypressJsonContent ) ;
123
+
124
+ // Cypress Json Base Url & Local true check
125
+ if ( ! Utils . isUndefined ( cypressJson . baseUrl ) && cypressJson . baseUrl . includes ( "localhost" ) && ! Utils . getLocalFlag ( bsConfig . connection_settings ) ) reject ( Constants . validationMessages . LOCAL_NOT_SET ) ;
126
+
127
+ // Detect if the user is not using the right directory structure, and throw an error
128
+ if ( ! Utils . isUndefined ( cypressJson . integrationFolder ) && ! Utils . isCypressProjDirValid ( bsConfig . run_settings . cypress_proj_dir , cypressJson . integrationFolder ) ) reject ( Constants . validationMessages . INCORRECT_DIRECTORY_STRUCTURE ) ;
129
+ }
130
+ } catch ( error ) {
121
131
reject ( Constants . validationMessages . INVALID_CYPRESS_JSON )
122
132
}
123
133
0 commit comments