Skip to content

Commit a1db395

Browse files
committed
don't print invalid json in case of local not set
1 parent 04547af commit a1db395

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

bin/commands/runs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ module.exports = function run(args) {
122122

123123
// display browserstack.json is not valid only if validation of browserstack.json field has failed, otherwise display just the error message
124124
// If parallels specified in arguments are invalid do not display browserstack.json is invalid message
125-
if (!(err === Constants.validationMessages.INVALID_PARALLELS_CONFIGURATION && !utils.isUndefined(args.parallels))) {
125+
if (utils.isJSONInvalid(err, args)) {
126126
logger.error(Constants.validationMessages.NOT_VALID);
127127
}
128128

bin/helpers/utils.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,3 +380,22 @@ exports.versionChangedMessage = (preferredVersion, actualVersion) => {
380380
message = message.replace("<actualVersion>", actualVersion);
381381
return message
382382
}
383+
384+
exports.isJSONInvalid = (err, args) => {
385+
let invalid = true
386+
387+
if (err === Constants.validationMessages.INVALID_PARALLELS_CONFIGURATION && !this.isUndefined(args.parallels)) {
388+
invalid = false
389+
}
390+
391+
if (this.deleteBaseUrlFromError(err) === this.deleteBaseUrlFromError(Constants.validationMessages.LOCAL_NOT_SET)) {
392+
invalid = false
393+
}
394+
395+
return invalid
396+
}
397+
398+
exports.deleteBaseUrlFromError = (err) => {
399+
return err.replace(/To test ([\s\S]*)on BrowserStack/g, 'To test on BrowserStack');
400+
}
401+

0 commit comments

Comments
 (0)