MCPcopy
hub / github.com/prisma/prisma / resolveNodeModulesBase

Function resolveNodeModulesBase

packages/internals/src/resolveOutput.ts:7–27  ·  view source on GitHub ↗
(cwd: string)

Source from the content-addressed store, hash-verified

5const exists = promisify(fs.exists)
6
7async function resolveNodeModulesBase(cwd: string): Promise<string> {
8 if (await exists(path.resolve(process.cwd(), 'prisma/schema.prisma'))) {
9 return process.cwd()
10 }
11 if (path.relative(process.cwd(), cwd) === 'prisma' && (await exists(path.resolve(process.cwd(), 'package.json')))) {
12 return process.cwd()
13 }
14 if (await exists(path.resolve(cwd, 'node_modules'))) {
15 return cwd
16 }
17 if (await exists(path.resolve(cwd, '../node_modules'))) {
18 return path.join(cwd, '../')
19 }
20 if (await exists(path.resolve(cwd, 'package.json'))) {
21 return cwd
22 }
23 if (await exists(path.resolve(cwd, '../package.json'))) {
24 return path.join(cwd, '../')
25 }
26 return cwd
27}
28
29export type ResolveOutputOptions = {
30 defaultOutput: string

Callers 1

resolveOutputFunction · 0.85

Calls 1

existsFunction · 0.70

Tested by

no test coverage detected