({ from, to, runtimeName, sourceMaps }: CopyRuntimeOptions)
| 616 | } |
| 617 | |
| 618 | async 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 |
no test coverage detected