Skip to content

Commit

Permalink
Simplify getting allBinNames
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekmaj committed Jul 12, 2024
1 parent ccf56e9 commit 1cfa1f6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
6 changes: 2 additions & 4 deletions sources/commands/Disable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,16 @@ export class DisableCommand extends Command<Context> {
? SupportedPackageManagerSetWithoutNpm
: this.names;

const binNamesMap = new Map<string, Set<string>>();
const allBinNames: string[] = [];

Check failure on line 53 in sources/commands/Disable.ts

View workflow job for this annotation

GitHub Actions / Testing chores

Array type using 'string[]' is forbidden. Use 'Array<string>' instead

for (const name of new Set(names)) {
if (!isSupportedPackageManager(name))
throw new UsageError(`Invalid package manager name '${name}'`);

const binNames = this.context.engine.getBinariesFor(name);
binNamesMap.set(name, binNames);
allBinNames.push(...binNames);
}

const allBinNames = Array.from(binNamesMap.values()).flatMap(binNames => Array.from(binNames));

await Promise.all(allBinNames.map(binName => {
if (process.platform === `win32`) {
return this.removeWin32Link(installDirectory, binName);
Expand Down
6 changes: 2 additions & 4 deletions sources/commands/Enable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,16 @@ export class EnableCommand extends Command<Context> {
? SupportedPackageManagerSetWithoutNpm
: this.names;

const binNamesMap = new Map<string, Set<string>>();
const allBinNames: string[] = [];

Check failure on line 63 in sources/commands/Enable.ts

View workflow job for this annotation

GitHub Actions / Testing chores

Array type using 'string[]' is forbidden. Use 'Array<string>' instead

for (const name of new Set(names)) {
if (!isSupportedPackageManager(name))
throw new UsageError(`Invalid package manager name '${name}'`);

const binNames = this.context.engine.getBinariesFor(name);
binNamesMap.set(name, binNames);
allBinNames.push(...binNames);
}

const allBinNames = Array.from(binNamesMap.values()).flatMap(binNames => Array.from(binNames));

await Promise.all(allBinNames.map(binName => {
if (process.platform === `win32`) {
return this.generateWin32Link(installDirectory, distFolder, binName);
Expand Down

0 comments on commit 1cfa1f6

Please sign in to comment.