Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added the ability to automatically detect the extension of the currents.config file and to look for the right file #1

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions packages/cypress-cloud/lib/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { bootCypress } from "../bootstrap";
import { warn } from "../log";
import { require } from "../require";
import { getRandomPort } from "../utils";
import fs from "fs";

const debug = Debug("currents:config");

Expand Down Expand Up @@ -62,10 +63,10 @@ export async function getMergedConfig(params: ValidatedCurrentsParameters) {
debug("resolving cypress config");
const cypressResolvedConfig:
| (Cypress.ResolvedConfigOptions & {
projectRoot: string;
rawJson: Record<string, unknown>;
browsers: DetectedBrowser[];
})
projectRoot: string;
rawJson: Record<string, unknown>;
browsers: DetectedBrowser[];
})
| undefined = await bootCypress(getRandomPort(), params);

debug("cypress resolvedConfig: %O", cypressResolvedConfig);
Expand Down Expand Up @@ -95,5 +96,18 @@ export async function getMergedConfig(params: ValidatedCurrentsParameters) {
}

function getConfigFilePath(projectRoot: string | null = null) {
return [projectRoot ?? process.cwd(), "currents.config.js"];
const filename = "currents.config";
const extensions = ["js", "cjs", "ejs", "ts"];
const filepaths: string[] = [];

for (const extension of extensions) {
const filepath = path.join(projectRoot ?? process.cwd(), `${filename}.${extension}`);
if (fs.existsSync(filepath)) {
filepaths.push(filepath);
} else {
console.warn(`${filepath} does not exist.`);
}
}

return filepaths;
}