(workspace)
| 811 | * @returns {Promise<string>} |
| 812 | */ |
| 813 | export async function createIndexJs(workspace) { |
| 814 | const version = await getVersion(); |
| 815 | let contents = `globalThis.CESIUM_VERSION = "${version}";\n`; |
| 816 | |
| 817 | // Iterate over all provided source files for the workspace and export the assignment based on file name. |
| 818 | const workspaceSources = workspaceSourceFiles[workspace]; |
| 819 | if (!workspaceSources) { |
| 820 | throw new Error(`Unable to find source files for workspace: ${workspace}`); |
| 821 | } |
| 822 | |
| 823 | const files = await globby(workspaceSources); |
| 824 | files.forEach(function (file) { |
| 825 | file = path.relative(`packages/${workspace}`, file); |
| 826 | |
| 827 | let moduleId = file; |
| 828 | moduleId = filePathToModuleId(moduleId); |
| 829 | |
| 830 | // Rename shader files, such that ViewportQuadFS.glsl is exported as _shadersViewportQuadFS in JS. |
| 831 | |
| 832 | let assignmentName = path.basename(file, path.extname(file)); |
| 833 | if (moduleId.indexOf(`Source/Shaders/`) === 0) { |
| 834 | assignmentName = `_shaders${assignmentName}`; |
| 835 | } |
| 836 | assignmentName = assignmentName.replace(/(\.|-)/g, "_"); |
| 837 | contents += `export { default as ${assignmentName} } from './${moduleId}.js';${EOL}`; |
| 838 | }); |
| 839 | |
| 840 | await writeFile(`packages/${workspace}/index.js`, contents, { |
| 841 | encoding: "utf-8", |
| 842 | }); |
| 843 | |
| 844 | return contents; |
| 845 | } |
| 846 | |
| 847 | /** |
| 848 | * Creates a single entry point file by importing all individual spec files. |
no test coverage detected
searching dependent graphs…