LocalServer.getAvailablePort = function()

in lib/LocalServer.js [179:187]


LocalServer.getAvailablePort = function (startPort, endPort) {
    const port = getRandomInt(startPort, endPort);
    return portChecker.check(port)
        .then((isInUse) => {
            if (!isInUse) return port;
            if (startPort < endPort) return LocalServer.getAvailablePort(startPort, endPort);
            throw new Error('Unable to find available port');
        });
};