Skip to content

Commit

Permalink
feat(types): export CurrentsConfig for typed config files
Browse files Browse the repository at this point in the history
  • Loading branch information
ynahmany authored Dec 9, 2024
2 parents 93f574e + e93aa7b commit 0e87239
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"singleQuote": false
}
1 change: 1 addition & 0 deletions packages/cypress-cloud/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import "source-map-support/register.js";

import { run as internalRun } from "./lib/run";
export type { CurrentsConfig } from "./lib/config/config";
import { CurrentsRunAPI } from "./types";
export type { CurrentsRunAPI } from "./types";
/**
Expand Down
12 changes: 10 additions & 2 deletions packages/cypress-cloud/lib/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ export type ComponentConfig = {
type RetryConfig = {
hardFailureMaxRetries: number;
};

/**
* This is the type for `currents.config.*s`. If you are not officially using TypeScript,
* you can still type the exported config in your IDE by adding the following as a block comment
* above `module.exports` / `export default`:
*
* `@type {import('cypress-cloud').CurrentsConfig}`
*/
export type CurrentsConfig = {
projectId?: string;
recordKey?: string;
Expand All @@ -43,7 +51,7 @@ const defaultConfig: CurrentsConfig = {

export async function getCurrentsConfig(
projectRoot?: string,
explicitConfigFilePath?: string
explicitConfigFilePath?: string,
): Promise<CurrentsConfig> {
if (_config) {
return _config;
Expand All @@ -70,7 +78,7 @@ export async function getCurrentsConfig(

warn(
"Failed to load config file, falling back to the default config. Attempted locations: %s",
configFilePath
configFilePath,
);
_config = defaultConfig;
return _config;
Expand Down

0 comments on commit 0e87239

Please sign in to comment.