(options: GenerateOptions)
| 40 | |
| 41 | await program.parseAsync(); |
| 42 | |
| 43 | async function generate(options: GenerateOptions): Promise<void> { |
| 44 | const selectedFormats = parseFormats(options.format); |
| 45 | const providers = await selectProviders(options.input, options.provider); |
| 46 | const targets = buildTargets(providers, options.provider); |
| 47 | |
| 48 | const writes: string[] = []; |
| 49 | |
| 50 | for (const target of targets) { |
| 51 | for (const format of selectedFormats) { |
| 52 | const file = render(format, target); |
| 53 | const outDir = path.join(options.output, file.format); |
| 54 | const outPath = path.join(outDir, `${target.id}.${file.extension}`); |
| 55 | await mkdir(outDir, { recursive: true }); |
| 56 | await writeFile(outPath, file.content, "utf8"); |
| 57 | writes.push(outPath); |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | for (const filePath of writes) { |
| 62 | console.log(filePath); |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | async function selectProviders(inputDir: string, providerOption: string): Promise<ProviderSource[]> { |
no test coverage detected