Skip to content

Commit 18bfc1d

Browse files
Merge pull request #173 from browserstack/wmic_deprecation
Remove ps-tree dependency which uses deprecated wmic, replace it with tree-kill
2 parents 6121b5a + 7d04492 commit 18bfc1d

File tree

3 files changed

+17
-170
lines changed

3 files changed

+17
-170
lines changed

lib/Local.js

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ var childProcess = require('child_process'),
77
LocalBinary = require('./LocalBinary'),
88
LocalError = require('./LocalError'),
99
version = require('../package.json').version,
10-
psTree = require('ps-tree');
10+
treeKill = require('tree-kill');
1111

1212
function Local(){
1313
this.sanitizePath = function(rawPath) {
@@ -342,32 +342,7 @@ function Local(){
342342
};
343343

344344
this.killAllProcesses = function(callback){
345-
psTree(this.pid, (err, children) => {
346-
var childPids = children.map(val => val.PID);
347-
var killChecker = setInterval(() => {
348-
if(childPids.length === 0) {
349-
clearInterval(killChecker);
350-
try {
351-
process.kill(this.pid);
352-
// This gives time to local binary to send kill signal to railsApp.
353-
setTimeout(() => {
354-
this.isProcessRunning = false;
355-
callback();
356-
}, 2000);
357-
} catch(err) {
358-
this.isProcessRunning = false;
359-
callback();
360-
}
361-
}
362-
for(var i in childPids) {
363-
try {
364-
process.kill(childPids[i]);
365-
} catch(err) {
366-
childPids.splice(i, 1);
367-
}
368-
}
369-
},500);
370-
});
345+
treeKill(this.pid, 'SIGTERM', callback);
371346
};
372347
}
373348

package-lock.json

Lines changed: 14 additions & 142 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"agent-base": "^6.0.2",
2222
"https-proxy-agent": "^5.0.1",
2323
"is-running": "^2.1.0",
24-
"ps-tree": "=1.2.0"
24+
"tree-kill": "^1.2.2"
2525
},
2626
"devDependencies": {
2727
"eslint": "^7.0.0",

0 commit comments

Comments
 (0)