11/* eslint-disable no-prototype-builtins */
2- import os from 'os' ;
3- import path from 'path' ;
4- import tcpPortUsed from 'tcp-port-used' ;
5- import getPort from 'get-port' ;
62import AsyncLock from 'async-lock' ;
7- import { IDevice } from './interfaces/IDevice' ;
3+ import asyncWait from 'async-wait-until' ;
4+ import axios from 'axios' ;
5+ import getPort from 'get-port' ;
86import _ from 'lodash' ;
9- import log from './logger' ;
10- import Cloud from './enums/Cloud' ;
117import normalizeUrl from 'normalize-url' ;
128import ora from 'ora' ;
13- import asyncWait from 'async-wait-until' ;
14- import axios from 'axios' ;
9+ import os from 'os' ;
10+ import path from 'path' ;
11+ import tcpPortUsed from 'tcp-port-used' ;
12+ import Cloud from './enums/Cloud' ;
1513import { FakeModuleLoader } from './fake-module-loader' ;
14+ import { IDevice } from './interfaces/IDevice' ;
1615import { IExternalModuleLoader } from './interfaces/IExternalModule' ;
16+ import log from './logger' ;
1717
1818const APPIUM_VENDOR_PREFIX = 'appium:' ;
1919
@@ -35,8 +35,8 @@ class PortManager {
3535 */
3636 async getAndAllocateFreePort ( portRange ?: string ) : Promise < number > {
3737 return this . lock . acquire ( 'port-allocation' , async ( ) => {
38+ // eslint-disable-next-line no-constant-condition
3839 while ( true ) {
39- let port : number ;
4040 let portOptions : number [ ] | undefined ;
4141
4242 // Determine which ports to try
@@ -59,7 +59,7 @@ class PortManager {
5959 }
6060
6161 // Get a free port from the system
62- port = portOptions ? await getPort ( { port : portOptions } ) : await getPort ( ) ;
62+ const port = portOptions ? await getPort ( { port : portOptions } ) : await getPort ( ) ;
6363
6464 // Atomically allocate it (we're in the lock, so this is safe)
6565 if ( ! this . allocatedPorts . has ( port ) ) {
0 commit comments