()
| 39 | names = Option.Rest(); |
| 40 | |
| 41 | async execute() { |
| 42 | let installDirectory = this.installDirectory; |
| 43 | |
| 44 | // Node always call realpath on the module it executes, so we already |
| 45 | // lost track of how the binary got called. To find it back, we need to |
| 46 | // iterate over the PATH variable. |
| 47 | if (typeof installDirectory === `undefined`) |
| 48 | installDirectory = path.dirname(await which(`corepack`)); |
| 49 | |
| 50 | const names = this.names.length === 0 |
| 51 | ? SupportedPackageManagerSetWithoutNpm |
| 52 | : this.names; |
| 53 | |
| 54 | const allBinNames: Array<string> = []; |
| 55 | |
| 56 | for (const name of new Set(names)) { |
| 57 | if (!isSupportedPackageManager(name)) |
| 58 | throw new UsageError(`Invalid package manager name '${name}'`); |
| 59 | |
| 60 | const binNames = this.context.engine.getBinariesFor(name); |
| 61 | allBinNames.push(...binNames); |
| 62 | } |
| 63 | |
| 64 | const removeLink = process.platform === `win32` ? |
| 65 | (binName: string) => this.removeWin32Link(installDirectory, binName) : |
| 66 | (binName: string) => this.removePosixLink(installDirectory, binName); |
| 67 | |
| 68 | await Promise.all(allBinNames.map(removeLink)); |
| 69 | } |
| 70 | |
| 71 | async removePosixLink(installDirectory: string, binName: string) { |
| 72 | const file = path.join(installDirectory, binName); |
nothing calls this directly
no test coverage detected