UNPKG

@cto.ai/ops

Version:

💻 CTO.ai - The CLI built for Teams 🚀

22 lines (21 loc) • 746 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getFirstActivePort = void 0; const tslib_1 = require("tslib"); const is_port_reachable_1 = tslib_1.__importDefault(require("is-port-reachable")); /** * Takes in an array of numbers, and returns the first one ith available port. * If no ports are available, return null */ const getFirstActivePort = async (ports) => { for (let i = 0; i < ports.length; i++) { const currentPort = ports[i]; if (typeof currentPort !== 'number') return null; if (!(await (0, is_port_reachable_1.default)(currentPort))) { return currentPort; } } return null; }; exports.getFirstActivePort = getFirstActivePort;