MCPcopy Create free account
hub / github.com/Noumena-Network/code / getInstallationPrefix

Function getInstallationPrefix

src/utils/autoUpdater.ts:280–300  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

278}
279
280async 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
302export async function checkGlobalInstallPermissions(): Promise<{
303 hasPermissions: boolean

Callers 1

Calls 2

execFileNoThrowWithCwdFunction · 0.85
logErrorFunction · 0.70

Tested by

no test coverage detected