* 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)
| 1444 | * @returns true if the path is npm-managed, false otherwise |
| 1445 | */ |
| 1446 | async 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 |
no outgoing calls
no test coverage detected