Skip to content

Commit 18d86f7

Browse files
author
Karan Nagpal
committed
Update API call for checking local binary running or not
1 parent d77645e commit 18d86f7

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

bin/commands/runs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ module.exports = function run(args, rawArgs) {
258258
utils.sendUsageReport(bsConfig, args, `${message}\n${dashboardLink}`, Constants.messageTypes.SUCCESS, null, buildReportData, rawArgs);
259259
return;
260260
}).catch(async function (err) {
261-
if (err && err.includes('browserstack.geoLocation')) {
261+
if (err && err.toString().includes('browserstack.geoLocation')) {
262262
err = err.replace(/browserstack.geoLocation/g, 'geolocation');
263263
}
264264
// Build creation failed

bin/helpers/utils.js

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -746,33 +746,29 @@ exports.generateLocalIdentifier = (mode) => {
746746

747747
exports.checkLocalIdentifierRunning = (bsConfig, localIdentifier) => {
748748
let options = {
749-
url: `${config.localTestingListUrl}?auth_token=${bsConfig.auth.access_key}&state=running`,
749+
url: `${config.cypress_v1}/local_binary_running_check`,
750750
auth: {
751751
user: bsConfig.auth.username,
752752
password: bsConfig.auth.access_key,
753753
},
754754
headers: {
755+
'Content-Type': 'application/json',
755756
'User-Agent': this.getUserAgent(),
756757
},
758+
body: JSON.stringify({ localIdentifier: localIdentifier}),
757759
};
758-
let that = this;
759760
return new Promise ( function(resolve, reject) {
760-
request.get(options, function (err, resp, body) {
761+
request.post(options, function (err, resp, body) {
761762
if(err){
762763
reject(err);
763764
}
765+
console.log(body);
764766
let response = JSON.parse(body);
765-
let localInstances = [];
766-
if(!that.isUndefined(response['instances'])){
767-
localInstances = response['instances'];
767+
if(response['should_spawn_binary'] == true){
768+
resolve(false);
769+
} else {
770+
resolve(true);
768771
}
769-
let localIdentifiers = [];
770-
771-
localInstances.forEach(function(instance){
772-
localIdentifiers.push(instance['localIdentifier']);
773-
});
774-
775-
resolve(localIdentifiers.includes(localIdentifier));
776772
});
777773
});
778774
};

0 commit comments

Comments
 (0)