( entryPath: string, entryType: FsEntryType | undefined, filesResolver: FilesResolver, )
| 17 | } |
| 18 | |
| 19 | async 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 | } |
no test coverage detected
searching dependent graphs…