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 (#1229)
  • Loading branch information
myarmolinsky authored Oct 22, 2024
1 parent a62719c commit 9671934
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {OCLIF_MARKER_OWNER, Performance} from '../performance'
import {settings} from '../settings'
import {determinePriority} from '../util/determine-priority'
import {safeReadJson} from '../util/fs'
import {toStandardizedId} from '../util/ids'
import {getHomeDir, getPlatform} from '../util/os'
import {compact, isProd} from '../util/util'
import {ux} from '../ux'
Expand Down Expand Up @@ -780,23 +781,27 @@ export class Config implements IConfig {
}

const handleAlias = (alias: string, hidden = false) => {
if (this._commands.has(alias)) {
const aliasWithDefaultTopicSeparator = toStandardizedId(alias, this)
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 9671934

Please sign in to comment.