"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.checkPort = exports.isPortInUse = void 0;
const tslib_1 = require("tslib");
const portfinder_1 = tslib_1.__importDefault(require("portfinder"));
const isPortInUse = async (port) => {
    portfinder_1.default.basePort = port;
    const freePort = await portfinder_1.default.getPortPromise();
    return freePort !== port;
};
exports.isPortInUse = isPortInUse;
const checkPort = async () => {
    const { port } = global.debugAppArgv;
    const inUse = await exports.isPortInUse(port);
    if (inUse) {
        console.error('EADDRINUSE: port %d is in use!', port);
        process.exit(1);
    }
};
exports.checkPort = checkPort;
