MCPcopy
hub / github.com/subquery/subql / getValidPort

Function getValidPort

packages/node-core/src/utils/project.ts:27–41  ·  view source on GitHub ↗
(argvPort?: number)

Source from the content-addressed store, hash-verified

25const logger = getLogger('Project-Utils');
26
27export 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
43export async function prepareProjectDir(projectPath: string): Promise<string> {
44 const stats = fs.statSync(projectPath);

Callers 1

bootstrapFunction · 0.90

Calls 3

findAvailablePortFunction · 0.90
exitWithErrorFunction · 0.90
validateFunction · 0.70

Tested by

no test coverage detected