You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
var exec = require('shelljs').exec;
var isWin = /^win/.test(process.platform);
var isPortOpen = function (port) { var cmd; if (isWin) cmd = 'netstat -an | find /i ":' + port + '" | find /i "listening"'; else cmd = 'lsof -i:' + port + " | tail -n 1 | awk '{print $2}'"; var portResponse = exec(cmd, { silent: true }).output; return portResponse ? false : true; }
module.exports = function (startPort) { while (!isPortOpen(startPort)) { startPort += 1; }
return startPort; }
|