FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Correctly handle errors by SCG82 · Pull Request #135 · browserstack/browserstack-local-nodejs · GitHub

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .js  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
9 changes: 5 additions & 4 deletions lib/Local.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ function Local(){
fs.unlinkSync(that.binaryPath);
delete(that.binaryPath);
that.start(options, callback);
return;
} else {
callback(new LocalError(error.toString()));
}
return;
}

var data = {};
Expand All @@ -106,7 +106,7 @@ function Local(){
else if(stderr)
data = JSON.parse(stderr);
else
callback(new LocalError('No output received'));
return callback(new LocalError('No output received'));

if(data['state'] != 'connected'){
callback(new LocalError(data['message']['message']));
Expand All @@ -123,10 +123,10 @@ function Local(){
return this.pid && running(this.pid) && this.isProcessRunning;
};

this.stop = function (callback) {
this.stop = function(callback) {
if(!this.pid) return callback();
this.killAllProcesses(function(error){
if(error) callback(new LocalError(error.toString()));
if(error) return callback(new LocalError(error.toString()));
callback();
});
};
Expand Down Expand Up @@ -316,6 +316,7 @@ function Local(){

this.killAllProcesses = function(callback){
psTree(this.pid, (err, children) => {
if(err) return callback(err);
var childPids = children.map(val => val.PID);
var killChecker = setInterval(() => {
if(childPids.length === 0) {
Expand Down

Back | FazBrowse Home | New Git URL