import { existsSync } from 'node:fs'; import { basename, resolve } from 'node:path'; const CEM_CONFIG_FILENAMES = [ 'custom-elements-manifest.config.js', 'custom-elements-manifest.config.mjs', 'custom-elements-manifest.config.cjs', 'custom-elements-manifest.config.ts', ]; /** Resolves the CEM config file in `cwd`. Shell globs like `config.*js` are unreliable on Windows. */ export function resolveCEMConfigPath(cwd: string): string | null { for (const name of CEM_CONFIG_FILENAMES) { const path = resolve(cwd, name); if (existsSync(path)) return path; } return null; } /** Returns the config filename for use with `cem analyze --config` when cwd is the package root. */ export function resolveCEMConfigArg(cwd: string): string | null { const path = resolveCEMConfigPath(cwd); return path ? basename(path) : null; }