MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / addExternalAsset

Function addExternalAsset

packages/cli/src/utils/publishProject.ts:192–212  ·  view source on GitHub ↗
(ctx: ExternalAssetContext, absPath: string)

Source from the content-addressed store, hash-verified

190}
191
192function 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
214function tryResolveExternal(
215 ctx: ExternalAssetContext,

Callers 1

tryResolveExternalFunction · 0.85

Calls 3

getMethod · 0.80
addMethod · 0.80
setMethod · 0.65

Tested by

no test coverage detected