MCPcopy
hub / github.com/prisma/prisma / readStudioAsset

Function readStudioAsset

packages/cli/src/Studio.ts:636–656  ·  view source on GitHub ↗
(fileName: string)

Source from the content-addressed store, hash-verified

634}
635
636async 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
658function getStudioAssetDirectories(): string[] {
659 return [...new Set([__dirname, join(__dirname, '..', 'build')])]

Callers 1

serveStudioAssetFunction · 0.85

Calls 4

joinFunction · 0.85
isNotFoundErrorFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected