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

Function downloadInstallAndBundle

packages/node/src/build.ts:69–133  ·  view source on GitHub ↗
({
  files,
  entrypoint,
  workPath,
  config,
  meta,
  considerBuildCommand,
}: DownloadOptions)

Source from the content-addressed store, hash-verified

67const libPathRegEx = /^node_modules|[/\\]node_modules[/\\]/;
68
69async function downloadInstallAndBundle({
70 files,
71 entrypoint,
72 workPath,
73 config,
74 meta,
75 considerBuildCommand,
76}: DownloadOptions) {
77 const downloadedFiles = await download(files, workPath, meta);
78 const entrypointFsDirname = join(workPath, dirname(entrypoint));
79 const nodeVersion = await getNodeVersion(
80 entrypointFsDirname,
81 undefined,
82 config,
83 meta
84 );
85
86 const {
87 cliType,
88 lockfilePath,
89 lockfileVersion,
90 packageJsonPackageManager,
91 turboSupportsCorepackHome,
92 } = await scanParentDirs(entrypointFsDirname, true);
93
94 const spawnEnv = getEnvForPackageManager({
95 cliType,
96 lockfileVersion,
97 packageJsonPackageManager,
98 env: process.env,
99 turboSupportsCorepackHome,
100 projectCreatedAt: config.projectSettings?.createdAt,
101 });
102
103 const installCommand = config.projectSettings?.installCommand;
104 if (typeof installCommand === 'string' && considerBuildCommand) {
105 if (installCommand.trim()) {
106 console.log(`Running "install" command: \`${installCommand}\`...`);
107 await execCommand(installCommand, {
108 env: spawnEnv,
109 cwd: entrypointFsDirname,
110 });
111 } else {
112 console.log(`Skipping "install" command...`);
113 }
114 } else {
115 await runNpmInstall(
116 entrypointFsDirname,
117 [],
118 { env: spawnEnv },
119 meta,
120 config.projectSettings?.createdAt
121 );
122 }
123 const entrypointPath = downloadedFiles[entrypoint].fsPath;
124 return {
125 entrypointPath,
126 entrypointFsDirname,

Callers 1

buildFunction · 0.70

Calls 7

downloadFunction · 0.90
getNodeVersionFunction · 0.90
scanParentDirsFunction · 0.90
getEnvForPackageManagerFunction · 0.90
execCommandFunction · 0.90
runNpmInstallFunction · 0.90
logMethod · 0.45

Tested by

no test coverage detected