| 69 | } |
| 70 | |
| 71 | async removePosixLink(installDirectory: string, binName: string) { |
| 72 | const file = path.join(installDirectory, binName); |
| 73 | try { |
| 74 | if (binName.includes(`yarn`) && corepackUtils.isYarnSwitchPath(await fs.promises.realpath(file))) { |
| 75 | console.warn(`${binName} is already installed in ${file} and points to a Yarn Switch install - skipping`); |
| 76 | return; |
| 77 | } |
| 78 | |
| 79 | await fs.promises.unlink(file); |
| 80 | } catch (err) { |
| 81 | if ((err as NodeError).code !== `ENOENT`) { |
| 82 | throw err; |
| 83 | } |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | async removeWin32Link(installDirectory: string, binName: string) { |
| 88 | for (const ext of [``, `.ps1`, `.cmd`]) { |