(argvPort?: number)
| 25 | const logger = getLogger('Project-Utils'); |
| 26 | |
| 27 | export async function getValidPort(argvPort?: number): Promise<number> { |
| 28 | const validate = (x: any) => { |
| 29 | const p = parseInt(x); |
| 30 | return isNaN(p) ? null : p; |
| 31 | }; |
| 32 | |
| 33 | const port = validate(argvPort) ?? (await findAvailablePort(DEFAULT_PORT)); |
| 34 | if (!port) { |
| 35 | const errMsg = `Unable to find available port (tried ports in range (${DEFAULT_PORT}..${ |
| 36 | DEFAULT_PORT + 10 |
| 37 | })). Try setting a free port manually by setting the --port flag`; |
| 38 | exitWithError(errMsg, logger); |
| 39 | } |
| 40 | return port; |
| 41 | } |
| 42 | |
| 43 | export async function prepareProjectDir(projectPath: string): Promise<string> { |
| 44 | const stats = fs.statSync(projectPath); |
no test coverage detected