MCPcopy
hub / github.com/prisma/prisma / processEntry

Function processEntry

packages/schema-files-loader/src/loadSchemaFiles.ts:19–57  ·  view source on GitHub ↗
(
  entryPath: string,
  entryType: FsEntryType | undefined,
  filesResolver: FilesResolver,
)

Source from the content-addressed store, hash-verified

17}
18
19async function processEntry(
20 entryPath: string,
21 entryType: FsEntryType | undefined,
22 filesResolver: FilesResolver,
23): Promise<LoadedFile[]> {
24 if (!entryType) {
25 return []
26 }
27 if (entryType.kind === 'symlink') {
28 const realPath = entryType.realPath
29 const realType = await filesResolver.getEntryType(realPath)
30 return processEntry(realPath, realType, filesResolver)
31 }
32
33 if (entryType.kind === 'file') {
34 if (path.extname(entryPath) !== '.prisma') {
35 return []
36 }
37 const content = await filesResolver.getFileContents(entryPath)
38 if (typeof content === 'undefined') {
39 return []
40 }
41 return [[entryPath, content]]
42 }
43
44 if (entryType.kind === 'directory') {
45 const dirEntries = await filesResolver.listDirContents(entryPath)
46 const nested = await Promise.all(
47 dirEntries.map(async (dirEntry) => {
48 const fullPath = path.join(entryPath, dirEntry)
49 const nestedEntryType = await filesResolver.getEntryType(fullPath)
50 return processEntry(fullPath, nestedEntryType, filesResolver)
51 }),
52 )
53 return nested.flat()
54 }
55
56 return []
57}

Callers 1

loadSchemaFilesFunction · 0.85

Calls 3

getEntryTypeMethod · 0.65
getFileContentsMethod · 0.65
listDirContentsMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…