* Determines the absolute path to the source directory.
()
| 22 | * Determines the absolute path to the source directory. |
| 23 | */ |
| 24 | function getSourceDir(): string { |
| 25 | const projectDir = process.cwd() |
| 26 | |
| 27 | const sourceRootFromTsConfig = getSourceDirFromTypeScriptConfig() |
| 28 | |
| 29 | if (sourceRootFromTsConfig) { |
| 30 | return path.join(projectDir, sourceRootFromTsConfig) |
| 31 | } |
| 32 | |
| 33 | // Check common source directories if there's no tsconfig.json |
| 34 | for (const dir of ['src', 'lib', 'app']) { |
| 35 | const absoluteSourceDir = path.join(projectDir, dir) |
| 36 | if (fs.existsSync(absoluteSourceDir)) { |
| 37 | return absoluteSourceDir |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | // Default fallback if we can't determine anything better |
| 42 | return projectDir |
| 43 | } |
| 44 | |
| 45 | function getSourceDirFromTypeScriptConfig(): string | undefined { |
| 46 | const tsconfig = getTsconfig() |
no test coverage detected