(ctx: ExternalAssetContext, absPath: string)
| 190 | } |
| 191 | |
| 192 | function addExternalAsset(ctx: ExternalAssetContext, absPath: string): string { |
| 193 | const existing = ctx.externalMap.get(absPath); |
| 194 | if (existing) return existing; |
| 195 | |
| 196 | const rel = relative(ctx.absProjectDir, absPath).replaceAll("\\", "/"); |
| 197 | const stripped = rel.replace(/^(?:\.\.\/)+/, ""); |
| 198 | let archivePath = `${EXT_ASSETS_PREFIX}/${stripped}`; |
| 199 | |
| 200 | if (ctx.usedArchivePaths.has(archivePath)) { |
| 201 | const ext = posix.extname(archivePath); |
| 202 | const base = archivePath.slice(0, archivePath.length - ext.length); |
| 203 | let i = 2; |
| 204 | while (ctx.usedArchivePaths.has(`${base}_${i}${ext}`)) i++; |
| 205 | archivePath = `${base}_${i}${ext}`; |
| 206 | } |
| 207 | |
| 208 | ctx.fileContents.set(archivePath, readFileSync(absPath)); |
| 209 | ctx.externalMap.set(absPath, archivePath); |
| 210 | ctx.usedArchivePaths.add(archivePath); |
| 211 | return archivePath; |
| 212 | } |
| 213 | |
| 214 | function tryResolveExternal( |
| 215 | ctx: ExternalAssetContext, |
no test coverage detected