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

Function getUpdateCommandInfo

packages/cli/src/util/get-update-command.ts:184–218  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

182}
183
184export async function getUpdateCommandInfo(): Promise<{
185 command: string;
186 global: boolean;
187}> {
188 const nativeInstall = isNativeBinaryInstall();
189 const pkgAndVersion = `${nativeInstall ? nativePackageName : packageName}@latest`;
190
191 if (nativeInstall) {
192 // The native binary's process.argv[1] points into its virtual filesystem
193 // snapshot, so detect the package manager from the real install location.
194 const segments = process.execPath.split(sep);
195 let cliType: GlobalCliType = 'npm';
196 if (segments.includes('pnpm') || segments.includes('.pnpm')) {
197 cliType = 'pnpm';
198 } else if (segments.includes('yarn') || segments.includes('.yarn')) {
199 cliType = 'yarn';
200 }
201 const install = cliType === 'yarn' ? 'global add' : 'i -g';
202 const force = cliType === 'npm' ? ' --force' : '';
203 return {
204 command: `${cliType} ${install} ${pkgAndVersion}${force}`,
205 global: true,
206 };
207 }
208
209 const { cliType, global } = await resolveInstall();
210 const yarn = cliType === 'yarn';
211
212 let install = yarn ? 'add' : 'i';
213 if (global) {
214 install = yarn ? 'global add' : 'i -g';
215 }
216
217 return { command: `${cliType} ${install} ${pkgAndVersion}`, global };
218}
219
220export default async function getUpdateCommand(): Promise<string> {
221 return (await getUpdateCommandInfo()).command;

Callers 3

executeUpgradeFunction · 0.90
getUpdateCommandFunction · 0.85

Calls 3

isNativeBinaryInstallFunction · 0.90
resolveInstallFunction · 0.85
splitMethod · 0.80

Tested by

no test coverage detected