Skip to content

Commit 8db8bdb

Browse files
07souravkundafrancisf
authored andcommitted
return only in sync case
1 parent ec262a2 commit 8db8bdb

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

lib/Local.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,16 @@ function Local(){
245245
conf.proxyHost = this.proxyHost;
246246
conf.proxyPort = this.proxyPort;
247247
}
248-
return callback ? this.binary.binaryPath(conf, callback) : this.binary.binaryPath(conf);
248+
if(!callback) {
249+
return this.binary.binaryPath(conf);
250+
}
251+
this.binary.binaryPath(conf, callback);
249252
} else {
250253
console.log('BINARY PATH IS DEFINED');
251-
return callback ? callback(this.binaryPath) : this.binaryPath;
254+
if(!callback) {
255+
return this.binaryPath;
256+
}
257+
callback(this.binaryPath);
252258
}
253259
};
254260

lib/LocalBinary.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ function LocalBinary(){
4949
if(err == null) {
5050
fs.unlinkSync(binaryPath);
5151
}
52-
return callback ? that.download(conf, destParentDir, callback, retries - 1) : that.downloadSync(conf, destParentDir, retries - 1);
52+
if(!callback) {
53+
return that.downloadSync(conf, destParentDir, retries - 1);
54+
}
55+
that.download(conf, destParentDir, callback, retries - 1);
5356
});
5457
} else {
5558
console.error('Number of retries to download exceeded.');
@@ -137,9 +140,15 @@ function LocalBinary(){
137140
var destBinaryName = (this.windows) ? 'BrowserStackLocal.exe' : 'BrowserStackLocal';
138141
var binaryPath = path.join(destParentDir, destBinaryName);
139142
if(this.checkPath(binaryPath, fs.X_OK)){
140-
return callback ? callback(binaryPath) : binaryPath;
143+
if(!callback) {
144+
return binaryPath;
145+
}
146+
callback(binaryPath);
141147
} else {
142-
return callback ? this.download(conf, destParentDir, callback, 5) : this.downloadSync(conf, destParentDir, 5);
148+
if(!callback) {
149+
return this.downloadSync(conf, destParentDir, 5);
150+
}
151+
this.download(conf, destParentDir, callback, 5);
143152
}
144153
};
145154

0 commit comments

Comments
 (0)