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