Skip to content

Commit ecd66ec

Browse files
committed
Adding cypress_config_filename and cypress_config_file after processing cli args
1 parent ef3f536 commit ecd66ec

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

bin/commands/runs.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ module.exports = function run(args) {
2424
// accept the build name from command line if provided
2525
utils.setBuildName(bsConfig, args);
2626

27+
// set cypress config filename
28+
utils.setCypressConfigFilename(bsConfig, args);
29+
2730
// Validate browserstack.json values and parallels specified via arguments
2831
return capabilityHelper.validate(bsConfig, args).then(function (validated) {
2932
logger.info(validated);

bin/helpers/utils.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,26 @@ exports.setBuildName = (bsConfig, args) => {
9595
}
9696
}
9797

98+
exports.searchForOption = (option) => {
99+
return (process.argv.indexOf(option) > -1);
100+
}
101+
102+
exports.verifyCypressConfigFileOption = () => {
103+
let ccfOptionsSet = (this.searchForOption('-ccf') || this.searchForOption('--ccf'));
104+
let cypressConfigFileSet = (this.searchForOption('-cypress-config-file') || this.searchForOption('--cypress-config-file'));
105+
let cypressConfigOptionsSet = (this.searchForOption('-cypressConfigFile') || this.searchForOption('--cypressConfigFile'));
106+
return (ccfOptionsSet || cypressConfigFileSet || cypressConfigOptionsSet);
107+
}
108+
109+
exports.setCypressConfigFilename = (bsConfig, args) => {
110+
let userPassedCypessConfigFile = this.verifyCypressConfigFileOption();
111+
112+
if (userPassedCypessConfigFile || this.isUndefined(bsConfig.run_settings.cypress_config_file)) {
113+
bsConfig.run_settings.cypress_config_filename = path.basename(args.cypressConfigFile);
114+
bsConfig.run_settings.cypress_config_file = args.cypressConfigFile;
115+
}
116+
}
117+
98118
exports.isUndefined = value => (value === undefined || value === null);
99119

100120
exports.isFloat = value => (Number(value) && Number(value) % 1 !== 0);

0 commit comments

Comments
 (0)