MCPcopy
hub / github.com/vitejs/vite / getPackageManagerCommand

Function getPackageManagerCommand

packages/vite/src/node/utils.ts:1704–1723  ·  view source on GitHub ↗
(
  type: CommandType = 'install',
)

Source from the content-addressed store, hash-verified

1702
1703type CommandType = 'install' | 'uninstall' | 'update'
1704export function getPackageManagerCommand(
1705 type: CommandType = 'install',
1706): string {
1707 const packageManager =
1708 process.env.npm_config_user_agent?.split(' ')[0].split('/')[0] || 'npm'
1709 switch (type) {
1710 case 'install':
1711 return packageManager === 'npm' ? 'npm install' : `${packageManager} add`
1712 case 'uninstall':
1713 return packageManager === 'npm'
1714 ? 'npm uninstall'
1715 : `${packageManager} remove`
1716 case 'update':
1717 return packageManager === 'yarn'
1718 ? 'yarn upgrade'
1719 : `${packageManager} update`
1720 default:
1721 throw new TypeError(`Unknown command type: ${type}`)
1722 }
1723}
1724
1725export function isDevServer(
1726 server: ViteDevServer | PreviewServer,

Callers 1

loadPreprocessorPathFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected