mozilla / fireplay-sublime

A fantastic plugin connecting your favorite editor with your favorite web debugger
47 stars 9 forks source link

Avoiding psutils #42

Closed nicola closed 10 years ago

nicola commented 10 years ago

I am only using a subset of psutil, so why not using commands straight away :)

module.exports = {
    overthrow: function(port, done) {
        var command, rpid;

        if(process.platform === 'darwin'){ // mac os
            command = 'lsof -i tcp:' + port + ' | grep node | grep -i listen';
            rpid = / \d+ /gm;
        }else{
            command = 'netstat -n -a -o | grep -i listening | grep :' + port;
            rpid = /\d+$/gm;
        }

        execute(command, rpid, done);
    }
};