(options: LoadConfigOptions = {})
| 33 | * the user's ~/.testsprite/credentials. |
| 34 | */ |
| 35 | export function loadConfig(options: LoadConfigOptions = {}): Config { |
| 36 | const env = options.env ?? process.env; |
| 37 | const profile = options.profile ?? env.TESTSPRITE_PROFILE ?? DEFAULT_PROFILE; |
| 38 | const credentialsPath = options.credentialsPath ?? defaultCredentialsPath(); |
| 39 | const fileEntry = readProfile(profile, { path: credentialsPath }); |
| 40 | |
| 41 | return { |
| 42 | apiUrl: options.endpointUrl ?? env.TESTSPRITE_API_URL ?? fileEntry?.apiUrl ?? DEFAULT_API_URL, |
| 43 | apiKey: env.TESTSPRITE_API_KEY ?? fileEntry?.apiKey, |
| 44 | profile, |
| 45 | }; |
| 46 | } |
no test coverage detected