MCPcopy Create free account
hub / github.com/vercel/vercel / downloadFilesInWorkPath

Function downloadFilesInWorkPath

packages/python/src/index.ts:333–370  ·  view source on GitHub ↗
({
  entrypoint,
  workPath,
  files,
  meta = {},
}: Pick<BuildOptions, 'workPath' | 'files' | 'meta'> & {
  entrypoint: string | undefined;
})

Source from the content-addressed store, hash-verified

331}
332
333export async function downloadFilesInWorkPath({
334 entrypoint,
335 workPath,
336 files,
337 meta = {},
338}: Pick<BuildOptions, 'workPath' | 'files' | 'meta'> & {
339 entrypoint: string | undefined;
340}) {
341 debug('Downloading user files...');
342 let downloadedFiles = await download(files, workPath, meta);
343 if (meta.isDev && entrypoint) {
344 const normalizedEntrypoint = entrypoint.endsWith('.py')
345 ? entrypoint
346 : `${entrypoint}.py`;
347 if (
348 !hasProp(downloadedFiles, entrypoint) &&
349 !hasProp(downloadedFiles, normalizedEntrypoint)
350 ) {
351 throw new NowBuildError({
352 code: 'PYTHON_ENTRYPOINT_NOT_FOUND',
353 message: `Configured Python entrypoint "${normalizedEntrypoint}" was not found.`,
354 link: PYTHON_ENTRYPOINT_DOCS_URL,
355 action: 'Learn More',
356 });
357 }
358
359 // Old versions of the CLI don't assign this property
360 const { devCacheDir = join(workPath, '.now', 'cache') } = meta;
361 // Replace dots in the entrypoint basename with underscores so the cache
362 // directory name doesn't collide with the entrypoint file itself.
363 const cacheKey = basename(entrypoint).replace(/\./g, '_');
364 const destCache = join(devCacheDir, cacheKey);
365 await download(downloadedFiles, destCache);
366 downloadedFiles = await glob('**', destCache);
367 workPath = destCache;
368 }
369 return workPath;
370}
371
372interface TargetPlatform {
373 /** uv-compatible platform triple, or undefined to use the host. */

Callers 1

buildFunction · 0.85

Calls 5

debugFunction · 0.90
downloadFunction · 0.90
globFunction · 0.90
replaceMethod · 0.80
hasPropFunction · 0.70

Tested by

no test coverage detected