MCPcopy
hub / github.com/prisma/prisma / copyRuntimeFiles

Function copyRuntimeFiles

packages/client-generator-js/src/generateClient.ts:618–641  ·  view source on GitHub ↗
({ from, to, runtimeName, sourceMaps }: CopyRuntimeOptions)

Source from the content-addressed store, hash-verified

616}
617
618async function copyRuntimeFiles({ from, to, runtimeName, sourceMaps }: CopyRuntimeOptions) {
619 const files = ['index-browser.js', 'index-browser.d.ts', 'wasm-compiler-edge.js']
620
621 files.push(`${runtimeName}.js`)
622 files.push(`${runtimeName}.d.ts`)
623
624 if (sourceMaps) {
625 files.push(...files.filter((file) => file.endsWith('.js')).map((file) => `${file}.map`))
626 }
627
628 await Promise.all(
629 files.map(async (file) => {
630 const sourcePath = path.join(from, file)
631 const targetPath = path.join(to, file)
632
633 if (file.endsWith('.js')) {
634 const content = await fs.readFile(sourcePath, 'utf-8')
635 await fs.writeFile(targetPath, addPreamble(content))
636 } else {
637 await fs.copyFile(sourcePath, targetPath)
638 }
639 }),
640 )
641}
642
643/**
644 * This function ensures that each generated client has unique package name

Callers 1

generateClientFunction · 0.85

Calls 2

addPreambleFunction · 0.90
pushMethod · 0.45

Tested by

no test coverage detected