diff --git a/sources/commands/Disable.ts b/sources/commands/Disable.ts index 68a99e6bd..204de3312 100644 --- a/sources/commands/Disable.ts +++ b/sources/commands/Disable.ts @@ -50,18 +50,21 @@ export class DisableCommand extends Command { ? SupportedPackageManagerSetWithoutNpm : this.names; + const allBinNames: Array = []; + for (const name of new Set(names)) { if (!isSupportedPackageManager(name)) throw new UsageError(`Invalid package manager name '${name}'`); - for (const binName of this.context.engine.getBinariesFor(name)) { - if (process.platform === `win32`) { - await this.removeWin32Link(installDirectory, binName); - } else { - await this.removePosixLink(installDirectory, binName); - } - } + const binNames = this.context.engine.getBinariesFor(name); + allBinNames.push(...binNames); } + + const removeLink = process.platform === `win32` ? + (binName: string) => this.removeWin32Link(installDirectory, binName) : + (binName: string) => this.removePosixLink(installDirectory, binName); + + await Promise.all(allBinNames.map(removeLink)); } async removePosixLink(installDirectory: string, binName: string) { diff --git a/sources/commands/Enable.ts b/sources/commands/Enable.ts index 5961584c0..c7bca84a4 100644 --- a/sources/commands/Enable.ts +++ b/sources/commands/Enable.ts @@ -60,18 +60,21 @@ export class EnableCommand extends Command { ? SupportedPackageManagerSetWithoutNpm : this.names; + const allBinNames: Array = []; + for (const name of new Set(names)) { if (!isSupportedPackageManager(name)) throw new UsageError(`Invalid package manager name '${name}'`); - for (const binName of this.context.engine.getBinariesFor(name)) { - if (process.platform === `win32`) { - await this.generateWin32Link(installDirectory, distFolder, binName); - } else { - await this.generatePosixLink(installDirectory, distFolder, binName); - } - } + const binNames = this.context.engine.getBinariesFor(name); + allBinNames.push(...binNames); } + + const generateLink = process.platform === `win32` ? + (binName: string) => this.generateWin32Link(installDirectory, distFolder, binName) : + (binName: string) => this.generatePosixLink(installDirectory, distFolder, binName); + + await Promise.all(allBinNames.map(generateLink)); } async generatePosixLink(installDirectory: string, distFolder: string, binName: string) { diff --git a/sources/commands/InstallGlobal.ts b/sources/commands/InstallGlobal.ts index 6161c4603..13eefeb1b 100644 --- a/sources/commands/InstallGlobal.ts +++ b/sources/commands/InstallGlobal.ts @@ -43,13 +43,13 @@ export class InstallGlobalCommand extends BaseCommand { if (this.args.length === 0) throw new UsageError(`No package managers specified`); - for (const arg of this.args) { + await Promise.all(this.args.map(arg => { if (arg.endsWith(`.tgz`)) { - await this.installFromTarball(path.resolve(this.context.cwd, arg)); + return this.installFromTarball(path.resolve(this.context.cwd, arg)); } else { - await this.installFromDescriptor(specUtils.parseSpec(arg, `CLI arguments`, {enforceExactVersion: false})); + return this.installFromDescriptor(specUtils.parseSpec(arg, `CLI arguments`, {enforceExactVersion: false})); } - } + })); } log(locator: Locator) { @@ -86,7 +86,6 @@ export class InstallGlobalCommand extends BaseCommand { if (segments.length > 0 && segments[segments.length - 1] !== `.corepack`) return; - if (segments.length < 3) { hasShortEntries = true; } else {