MCPcopy
hub / github.com/codeaashu/claude-code / isNpmSymlink

Function isNpmSymlink

src/utils/nativeInstaller/installer.ts:1446–1458  ·  view source on GitHub ↗

* Check if a given path is managed by npm * @param executablePath - The path to check (can be a symlink) * @returns true if the path is npm-managed, false otherwise

(executablePath: string)

Source from the content-addressed store, hash-verified

1444 * @returns true if the path is npm-managed, false otherwise
1445 */
1446async function isNpmSymlink(executablePath: string): Promise<boolean> {
1447 // Resolve symlink to its target if applicable
1448 let targetPath = executablePath
1449 const stats = await lstat(executablePath)
1450 if (stats.isSymbolicLink()) {
1451 targetPath = await realpath(executablePath)
1452 }
1453
1454 // checking npm prefix isn't guaranteed to work, as prefix can change
1455 // and users may set --prefix manually when installing
1456 // thus we use this heuristic:
1457 return targetPath.endsWith('.js') || targetPath.includes('node_modules')
1458}
1459
1460/**
1461 * Remove the claude symlink from the executable directory

Callers 1

removeInstalledSymlinkFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected