UNPKG

genaiscript

Version:

A CLI for GenAIScript, a generative AI scripting framework.

15 lines 572 B
// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. import { findRandomOpenPort, isPortInUse, logWarn } from "@genaiscript/core"; export async function findOpenPort(defaultPort, options) { let port = parseInt(options.port) || defaultPort; if (await isPortInUse(port)) { if (options.port) throw new Error(`port ${port} in use`); const oldPort = port; port = await findRandomOpenPort(); logWarn(`port ${oldPort} in use, using port ${port}`); } return port; } //# sourceMappingURL=port.js.map