( inputDir: string, outputDir: string, depth: number | typeof Infinity )
| 95 | } |
| 96 | |
| 97 | async function processDirectory( |
| 98 | inputDir: string, |
| 99 | outputDir: string, |
| 100 | depth: number | typeof Infinity |
| 101 | ): Promise<void> { |
| 102 | await fs.mkdir(outputDir, { recursive: true }); |
| 103 | const entries = await fs.readdir(inputDir, { withFileTypes: true }); |
| 104 | |
| 105 | for (const entry of entries) { |
| 106 | const inputPath = path.join(inputDir, entry.name); |
| 107 | const outputPath = path.join(outputDir, entry.name); |
| 108 | |
| 109 | if (entry.isDirectory()) { |
| 110 | if (depth === 0) { |
| 111 | continue; |
| 112 | } |
| 113 | const nextDepth = depth === Infinity ? Infinity : depth - 1; |
| 114 | await processDirectory(inputPath, outputPath, nextDepth); |
| 115 | continue; |
| 116 | } |
| 117 | |
| 118 | if (!entry.isFile()) { |
| 119 | continue; |
| 120 | } |
| 121 | |
| 122 | const ext = path.extname(entry.name); |
| 123 | if (ext === MIRROW_EXTENSION) { |
| 124 | await compileMirrowFile(inputPath, toSvgPath(outputDir, entry.name)); |
| 125 | } else { |
| 126 | await copyAsset(inputPath, outputPath); |
| 127 | } |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | function resolveOutputFilePath(output: string): string { |
| 132 | return path.extname(output) ? output : `${output}.svg`; |
no test coverage detected