MCPcopy
hub / github.com/prisma/prisma / readSchemaFromFileOrDirectory

Function readSchemaFromFileOrDirectory

packages/internals/src/cli/getSchema.ts:139–159  ·  view source on GitHub ↗
(schemaPath: string)

Source from the content-addressed store, hash-verified

137}
138
139async function readSchemaFromFileOrDirectory(schemaPath: string): Promise<LookupResult> {
140 let stats: fs.Stats
141 try {
142 stats = await stat(schemaPath)
143 } catch (e) {
144 if (e.code === 'ENOENT') {
145 return { ok: false, error: { kind: 'NotFound', path: schemaPath } }
146 }
147 throw e
148 }
149
150 if (stats.isFile()) {
151 return readSchemaFromSingleFile(schemaPath)
152 }
153
154 if (stats.isDirectory()) {
155 return readSchemaFromDirectory(schemaPath)
156 }
157
158 return { ok: false, error: { kind: 'WrongType', path: schemaPath, expectedTypes: ['file', 'directory'] } }
159}
160
161/**
162 * Tries to load schema from either provided

Callers 2

getCliProvidedSchemaFileFunction · 0.85

Calls 3

statFunction · 0.85
readSchemaFromSingleFileFunction · 0.85
readSchemaFromDirectoryFunction · 0.85

Tested by

no test coverage detected