MCPcopy
hub / github.com/prisma/prisma / getSourceDir

Function getSourceDir

packages/cli/src/utils/client-output-path.ts:24–43  ·  view source on GitHub ↗

* Determines the absolute path to the source directory.

()

Source from the content-addressed store, hash-verified

22 * Determines the absolute path to the source directory.
23 */
24function 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
45function getSourceDirFromTypeScriptConfig(): string | undefined {
46 const tsconfig = getTsconfig()

Callers 1

Calls 1

Tested by

no test coverage detected