@@ -67,10 +67,14 @@ const caps = (bsConfig, zip) => {
6767 obj . callbackURL = bsConfig . run_settings . callback_url ;
6868 obj . projectNotifyURL = bsConfig . run_settings . project_notify_URL ;
6969 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+ }
7074 }
7175
7276 if ( obj . parallels === Constants . constants . DEFAULT_PARALLEL_MESSAGE ) obj . parallels = undefined
73-
77+
7478 if ( obj . project ) logger . log ( `Project name is: ${ obj . project } ` ) ;
7579
7680 if ( obj . customBuildName ) logger . log ( `Build name is: ${ obj . customBuildName } ` ) ;
@@ -106,18 +110,24 @@ const validate = (bsConfig, args) => {
106110 // if parallels specified via arguments validate only arguments
107111 if ( ! Utils . isUndefined ( args ) && ! Utils . isUndefined ( args . parallels ) && ! Utils . isParallelValid ( args . parallels ) ) reject ( Constants . validationMessages . INVALID_PARALLELS_CONFIGURATION ) ;
108112
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 ) ;
110118
111119 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 ) {
121131 reject ( Constants . validationMessages . INVALID_CYPRESS_JSON )
122132 }
123133
0 commit comments