MCPcopy Create free account
hub / github.com/TestSprite/testsprite-cli / resolveReportedEndpoint

Function resolveReportedEndpoint

src/commands/init.ts:37–47  ·  view source on GitHub ↗

* Resolve the endpoint the summary should report, using the SAME precedence * `runConfigure` uses to pick (and persist) the endpoint: * --endpoint-url > TESTSPRITE_API_URL env > existing profile apiUrl > prod default. * Reporting a flat prod default would falsely claim a prod target after

(opts: InitOptions, deps: InitDeps)

Source from the content-addressed store, hash-verified

35 * is written, so the persisted apiUrl is reflected faithfully.
36 */
37function resolveReportedEndpoint(opts: InitOptions, deps: InitDeps): string {
38 const env = deps.env ?? process.env;
39 const envApiUrl = env.TESTSPRITE_API_URL?.trim() || undefined;
40 let existing: string | undefined;
41 try {
42 existing = readProfile(opts.profile, { path: deps.credentialsPath })?.apiUrl;
43 } catch {
44 existing = undefined;
45 }
46 return opts.endpointUrl ?? envApiUrl ?? existing ?? DEFAULT_API_URL;
47}
48
49// ---------------------------------------------------------------------------
50// Types

Callers 1

runInitFunction · 0.85

Calls 1

readProfileFunction · 0.85

Tested by

no test coverage detected