MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / freePort

Function freePort

e2e/local/vite-dev-routing.test.ts:30–38  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

28`;
29
30const freePort = (): Promise<number> =>
31 new Promise((resolve, reject) => {
32 const srv = net.createServer();
33 srv.on("error", reject);
34 srv.listen(0, "127.0.0.1", () => {
35 const port = (srv.address() as net.AddressInfo).port;
36 srv.close(() => resolve(port));
37 });
38 });
39
40const readToken = async (dataDir: string): Promise<string> => {
41 const path = join(dataDir, "server-control", "auth.json");

Callers 1

startPlainViteDevFunction · 0.70

Calls 4

listenMethod · 0.80
addressMethod · 0.80
closeMethod · 0.65
resolveFunction · 0.50

Tested by

no test coverage detected