(fileName: string)
| 634 | } |
| 635 | |
| 636 | async function readStudioAsset(fileName: string): Promise<Buffer | string> { |
| 637 | const triedPaths: string[] = [] |
| 638 | |
| 639 | for (const directory of getStudioAssetDirectories()) { |
| 640 | const filePath = join(directory, fileName) |
| 641 | triedPaths.push(filePath) |
| 642 | |
| 643 | try { |
| 644 | return await readFile(filePath) |
| 645 | } catch (error: unknown) { |
| 646 | if (!isNotFoundError(error)) { |
| 647 | throw error |
| 648 | } |
| 649 | } |
| 650 | } |
| 651 | |
| 652 | const error = new Error(`Prisma Studio asset "${fileName}" was not found.`) as Error & { code?: string } |
| 653 | error.code = 'ENOENT' |
| 654 | error.message = `${error.message}\nSearched in:\n${triedPaths.map((filePath) => `- ${filePath}`).join('\n')}` |
| 655 | throw error |
| 656 | } |
| 657 | |
| 658 | function getStudioAssetDirectories(): string[] { |
| 659 | return [...new Set([__dirname, join(__dirname, '..', 'build')])] |
no test coverage detected