Skip to content
This repository was archived by the owner on Jul 30, 2025. It is now read-only.

Commit 9ffa5d9

Browse files
committed
fix(packages/core): commands for plugin didn't handle no-usage case
Fixes #2949
1 parent 8e813f6 commit 9ffa5d9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/core/src/plugins/commands.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,12 @@ export default async function commandsOffered(plugin?: string): Promise<Tables.T
5656
prefix = `/${A[1]}`,
5757
subtree = usage[prefix]
5858
): Errors.UsageModel {
59+
if (!subtree) {
60+
return
61+
}
5962
if (A.length - idx === 0) {
6063
return subtree.usage
64+
} else if (!subtree.children) {
6165
} else {
6266
const prefixPlus = `${prefix}/${A[idx]}`
6367
return find(command, A, idx + 1, prefixPlus, subtree.children[prefixPlus])
@@ -71,7 +75,7 @@ export default async function commandsOffered(plugin?: string): Promise<Tables.T
7175
},
7276
body: commands
7377
.map(command => ({ command, usage: find(command), name: command.replace(/^\//, '').replace(/\//g, ' ') }))
74-
.filter(_ => !_.usage.synonymFor && !_.usage.children)
78+
.filter(_ => !_.usage || (!_.usage.synonymFor && !_.usage.children))
7579
.map(({ command, name }) => ({
7680
type: 'command',
7781
name,

0 commit comments

Comments
 (0)