MCPcopy
hub / github.com/tailwindlabs/tailwindcss / getRandomPort

Function getRandomPort

integrations/utils.ts:725–741  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

723}
724
725export async function getRandomPort() {
726 return new Promise<number>((resolve, reject) => {
727 let server = createServer()
728 server.unref()
729 server.on('error', reject)
730 server.listen(0, '127.0.0.1', () => {
731 let address = server.address()
732 server.close(() => {
733 if (address && typeof address === 'object') {
734 resolve(address.port)
735 } else {
736 reject(new Error('Unable to allocate random port'))
737 }
738 })
739 })
740 })
741}
742
743async function killProcessTree(child: ChildProcess) {
744 if (child.exitCode !== null || child.signalCode !== null || child.pid === undefined) {

Callers 1

nuxt.test.tsFile · 0.90

Calls 2

createServerFunction · 0.85
resolveFunction · 0.50

Tested by

no test coverage detected