UNPKG

@cto.ai/ops

Version:

💻 CTO.ai Ops - The CLI built for Teams 🚀

20 lines (19 loc) • 657 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); 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 */ exports.getFirstActivePort = async (ports) => { for (let i = 0; i < ports.length; i++) { const currentPort = ports[i]; if (typeof currentPort !== 'number') return null; if (!(await is_port_reachable_1.default(currentPort))) { return currentPort; } } return null; };