MCPcopy Index your code
hub / github.com/code-pushup/cli / detectFramework

Function detectFramework

packages/plugin-coverage/src/lib/binding.ts:213–240  ·  view source on GitHub ↗
(targetDir: string)

Source from the content-addressed store, hash-verified

211}
212
213async function detectFramework(targetDir: string): Promise<Framework> {
214 const files = await readdir(targetDir, { encoding: 'utf8' });
215 const hasVitestConfig = files.some(
216 file => VITEST_CONFIG.test(file) || VITEST_WORKSPACE.test(file),
217 );
218 const hasJestConfig = files.some(file => JEST_CONFIG.test(file));
219 if (hasVitestConfig) {
220 return 'vitest';
221 }
222 if (hasJestConfig) {
223 return 'jest';
224 }
225 try {
226 const packageJson = await readJsonFile<{
227 dependencies?: Record<string, string>;
228 devDependencies?: Record<string, string>;
229 }>(path.join(targetDir, 'package.json'));
230 if (hasDependency(packageJson, 'vitest')) {
231 return 'vitest';
232 }
233 if (hasDependency(packageJson, 'jest')) {
234 return 'jest';
235 }
236 } catch {
237 return 'other';
238 }
239 return 'other';
240}
241
242async function detectConfigFile(
243 targetDir: string,

Callers 2

binding.tsFile · 0.85
isRecommendedFunction · 0.85

Calls 1

hasDependencyFunction · 0.90

Tested by

no test coverage detected