(targetDir: string)
| 211 | } |
| 212 | |
| 213 | async 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 | |
| 242 | async function detectConfigFile( |
| 243 | targetDir: string, |
no test coverage detected