Skip to content

Commit

Permalink
fix: fix aliases in config.commandIDs missing the default topic separ…
Browse files Browse the repository at this point in the history
…ator
  • Loading branch information
myarmolinsky committed Oct 22, 2024
1 parent a62719c commit 3f5ff6f
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export class Config implements IConfig {

public get commandIDs(): string[] {
if (this._commandIDs) return this._commandIDs
this._commandIDs = this.commands.map((c) => c.id)
this._commandIDs = this.commands.map((c) => c.id.split(' ').join(':'))
return this._commandIDs
}

Expand Down Expand Up @@ -780,23 +780,27 @@ export class Config implements IConfig {
}

const handleAlias = (alias: string, hidden = false) => {
if (this._commands.has(alias)) {
const aliasWithDefaultTopicSeparator = alias.replaceAll(' ', ':')
if (this._commands.has(aliasWithDefaultTopicSeparator)) {
const prioritizedCommand = determinePriority(this.pjson.oclif.plugins ?? [], [
this._commands.get(alias)!,
this._commands.get(aliasWithDefaultTopicSeparator)!,
command,
])
this._commands.set(alias, {...prioritizedCommand, id: alias})
this._commands.set(aliasWithDefaultTopicSeparator, {
...prioritizedCommand,
id: aliasWithDefaultTopicSeparator,
})
} else {
this._commands.set(alias, {...command, hidden, id: alias})
this._commands.set(aliasWithDefaultTopicSeparator, {...command, hidden, id: aliasWithDefaultTopicSeparator})
}

// set every permutation of the aliases
// v3 moved command alias permutations to the manifest, but some plugins may not have
// the new manifest yet. For those, we need to calculate the permutations here.
const aliasPermutations =
this.flexibleTaxonomy && command.aliasPermutations === undefined
? getCommandIdPermutations(alias)
: (command.permutations ?? [alias])
? getCommandIdPermutations(aliasWithDefaultTopicSeparator)
: (command.permutations ?? [aliasWithDefaultTopicSeparator])
// set every permutation
for (const permutation of aliasPermutations) {
this.commandPermutations.add(permutation, command.id)
Expand Down

0 comments on commit 3f5ff6f

Please sign in to comment.