diff --git a/bin/commands/info.js b/bin/commands/info.js index c9df195a..a5cdf2ee 100644 --- a/bin/commands/info.js +++ b/bin/commands/info.js @@ -18,6 +18,9 @@ module.exports = function info(args) { utils.setUsageReportingFlag(bsConfig, args.disableUsageReporting); + // set cypress config filename + utils.setCypressConfigFilename(bsConfig, args); + let buildId = args._[1]; let options = { diff --git a/bin/commands/init.js b/bin/commands/init.js index 6bd7246b..5be4fa33 100644 --- a/bin/commands/init.js +++ b/bin/commands/init.js @@ -13,6 +13,8 @@ function get_path(args) { if (filename !== path.basename(filename)) { let message = Constants.userMessages.CONFLICTING_INIT_ARGUMENTS; logger.error(message); + // set cypress config filename + utils.setCypressConfigFilename(args.bstack_config, args); utils.sendUsageReport(null, args, message, Constants.messageTypes.ERROR, 'conflicting_path_json_init'); return; } diff --git a/bin/commands/stop.js b/bin/commands/stop.js index 8d4b5665..0560018f 100644 --- a/bin/commands/stop.js +++ b/bin/commands/stop.js @@ -18,6 +18,9 @@ module.exports = function stop(args) { utils.setUsageReportingFlag(bsConfig, args.disableUsageReporting); + // set cypress config filename + utils.setCypressConfigFilename(bsConfig, args); + let buildId = args._[1]; let options = { diff --git a/bin/helpers/usageReporting.js b/bin/helpers/usageReporting.js index 1cd68e45..9a25c7ef 100644 --- a/bin/helpers/usageReporting.js +++ b/bin/helpers/usageReporting.js @@ -33,7 +33,7 @@ function local_cypress_version(bsConfig) { // 1. check version of Cypress installed in local project // 2. check version of Cypress installed globally if not present in project - if (bsConfig) { + if (bsConfig && bsConfig.run_settings.cypressProjectDir) { let version = get_version(path.join(bsConfig.run_settings.cypressProjectDir, 'node_modules', '.bin', 'cypress')); if (!version) { version = get_version('cypress'); @@ -80,7 +80,7 @@ function cli_version_and_path(bsConfig) { // 1. check version of Cypress installed in local project // 2. check version of Cypress installed globally if not present in project - if (bsConfig) { + if (bsConfig && bsConfig.run_settings.cypressProjectDir) { let _path = path.join(bsConfig.run_settings.cypressProjectDir, 'node_modules', 'browserstack-cypress'); let version = get_version(_path); if (!version) { diff --git a/bin/helpers/utils.js b/bin/helpers/utils.js index 8c3e4622..8fdd2167 100644 --- a/bin/helpers/utils.js +++ b/bin/helpers/utils.js @@ -164,7 +164,7 @@ exports.setCypressConfigFilename = (bsConfig, args) => { bsConfig.run_settings.userProvidedCypessConfigFile = (userProvidedCypessConfigFile || (!this.isUndefined(bsConfig.run_settings.cypress_config_file))); - if (userProvidedCypessConfigFile || this.isUndefined(bsConfig.run_settings.cypress_config_file)) { + if ((userProvidedCypessConfigFile || this.isUndefined(bsConfig.run_settings.cypress_config_file)) && !this.isUndefined(args.cypressConfigFile)) { bsConfig.run_settings.cypress_config_file = args.cypressConfigFile; bsConfig.run_settings.cypress_config_filename = path.basename(args.cypressConfigFile); } else if (!this.isUndefined(bsConfig.run_settings.cypress_config_file)) {