Skip to content

Commit ff529c8

Browse files
committed
Ensure calling .stop does not error if callback is not passed in
1 parent 84ade59 commit ff529c8

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

lib/Local.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ function Local(){
104104
};
105105

106106
this.stop = function (callback) {
107+
if(typeof callback === 'undefined')
108+
callback = function() {};
107109
if(!this.pid) return callback();
108110
this.opcode = 'stop';
109111
this.tunnel = childProcess.execFile(this.binaryPath, this.getBinaryArgs(), function(error){

test/local.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,9 @@ describe('Local', function () {
182182
});
183183

184184
it('should set proxy', function (done) {
185-
bsLocal.start({
186-
'key': process.env.BROWSERSTACK_ACCESS_KEY,
187-
onlyCommand: true,
185+
bsLocal.start({
186+
'key': process.env.BROWSERSTACK_ACCESS_KEY,
187+
onlyCommand: true,
188188
'proxyHost': 'localhost',
189189
'proxyPort': 8080,
190190
'proxyUser': 'user',
@@ -208,7 +208,14 @@ describe('Local', function () {
208208
expect(bsLocal.getBinaryArgs().indexOf('localhost,8000,0')).to.not.equal(-1);
209209
done();
210210
});
211-
});
211+
})
212+
213+
it('does not error if no callback in stop', function (done) {
214+
bsLocal.start({ 'key': process.env.BROWSERSTACK_ACCESS_KEY }, function(){
215+
bsLocal.stop();
216+
done();
217+
});
218+
})
212219

213220
afterEach(function (done) {
214221
this.timeout(60000);

0 commit comments

Comments
 (0)