(defaultPort = Math.ceil(Math.random() * 30000) + 15000)
| 60 | * so we use `15000` ~ `45000`. |
| 61 | */ |
| 62 | export async function getRandomPort(defaultPort = Math.ceil(Math.random() * 30000) + 15000) { |
| 63 | let port = defaultPort; |
| 64 | while (true) { |
| 65 | if (!portMap.get(port) && (await isPortAvailable(port))) { |
| 66 | portMap.set(port, 1); |
| 67 | return port; |
| 68 | } |
| 69 | port++; |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | // fast-glob only accepts posix path |
| 74 | // https://github.com/mrmlnc/fast-glob#convertpathtopatternpath |
searching dependent graphs…