Skip to content

Commit b03a873

Browse files
committed
refactor
1 parent e03b496 commit b03a873

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

bin/commands/runs.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@ module.exports = function run(args) {
1717
return utils.validateBstackJson(bsConfigPath).then(function (bsConfig) {
1818
utils.setUsageReportingFlag(bsConfig, args.disableUsageReporting);
1919

20-
// setting setDefaultAuthHash to {} if not present and set via env variables or via args.
21-
utils.setDefaultAuthHash(bsConfig,args);
22-
23-
// setting npm_dependencies to {} if not present
24-
utils.setDefaultNpmHash(bsConfig);
20+
utils.setDefaults(bsConfig, args);
2521

2622
// accept the username from command line or env variable if provided
2723
utils.setUsername(bsConfig, args);

bin/helpers/utils.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,18 +115,14 @@ exports.setParallels = (bsConfig, args) => {
115115
}
116116
};
117117

118-
exports.setDefaultAuthHash = (bsConfig, args) => {
119-
if (
120-
this.isUndefined(bsConfig['auth']) &&
121-
(!this.isUndefined(args.username) ||
122-
!this.isUndefined(process.env.BROWSERSTACK_USERNAME))
123-
) {
118+
exports.setDefaults = (bsConfig, args) => {
119+
// setting setDefaultAuthHash to {} if not present and set via env variables or via args.
120+
if (this.isUndefined(bsConfig['auth']) && (!this.isUndefined(args.username) || !this.isUndefined(process.env.BROWSERSTACK_USERNAME))) {
124121
bsConfig['auth'] = {};
125122
}
126-
}
127123

128-
exports.setDefaultNpmHash = (bsConfig) => {
129-
if (bsConfig.run_settings && !bsConfig.run_settings.npm_dependencies) {
124+
// setting npm_dependencies to {} if not present
125+
if (bsConfig.run_settings && this.isUndefined(bsConfig.run_settings.npm_dependencies)) {
130126
bsConfig.run_settings.npm_dependencies = {}
131127
}
132128
}

0 commit comments

Comments
 (0)