()
| 268 | } |
| 269 | |
| 270 | async function getInstallationPrefix(): Promise<string | null> { |
| 271 | // Run from home directory to avoid reading project-level .npmrc/.bunfig.toml |
| 272 | const isBun = env.isRunningWithBun() |
| 273 | let prefixResult = null |
| 274 | if (isBun) { |
| 275 | prefixResult = await execFileNoThrowWithCwd('bun', ['pm', 'bin', '-g'], { |
| 276 | cwd: homedir(), |
| 277 | }) |
| 278 | } else { |
| 279 | prefixResult = await execFileNoThrowWithCwd( |
| 280 | 'npm', |
| 281 | ['-g', 'config', 'get', 'prefix'], |
| 282 | { cwd: homedir() }, |
| 283 | ) |
| 284 | } |
| 285 | if (prefixResult.code !== 0) { |
| 286 | logError(new Error(`Failed to check ${isBun ? 'bun' : 'npm'} permissions`)) |
| 287 | return null |
| 288 | } |
| 289 | return prefixResult.stdout.trim() |
| 290 | } |
| 291 | |
| 292 | export async function checkGlobalInstallPermissions(): Promise<{ |
| 293 | hasPermissions: boolean |
no test coverage detected