Skip to content

Commit

Permalink
fix: forwards compatiblity
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonnalley committed Jan 18, 2023
1 parent ff798e8 commit 3aea844
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {format} from 'util'

import {Options, Plugin as IPlugin} from '../interfaces/plugin'
import {Config as IConfig, ArchTypes, PlatformTypes, LoadOptions} from '../interfaces/config'
import {ArgInput, Command, CompletableOptionFlag, Hook, Hooks, PJSON, Topic} from '../interfaces'
import {Command, CompletableOptionFlag, Hook, Hooks, PJSON, Topic} from '../interfaces'
import * as Plugin from './plugin'
import {Debug, compact, loadJSON, collectUsableIds, getCommandIdPermutations} from './util'
import {isProd} from '../util'
Expand Down Expand Up @@ -787,7 +787,8 @@ export async function toCached(c: Command.Class, plugin?: IPlugin): Promise<Comm
}

// v2 commands have args as an object, so we need to normalize it to an array for forwards compatibility
const normalized = (Array.isArray(c.args) ? c.args ?? [] : Object.values(c.args ?? {})) as ArgInput
// @ts-ignore
const normalized = Array.isArray(c.args) ? c.args ?? [] : Object.entries(c.args ?? {}).map(([name, arg]) => ({...arg, name}))
const argsPromise = normalized.map(async a => ({
name: a.name,
description: a.description,
Expand Down Expand Up @@ -819,7 +820,7 @@ export async function toCached(c: Command.Class, plugin?: IPlugin): Promise<Comm
}

// do not include these properties in manifest
const ignoreCommandProperties = ['plugin', '_flags', '_enableJsonFlag', '_globalFlags']
const ignoreCommandProperties = ['plugin', '_flags', '_enableJsonFlag', '_globalFlags', '_baseFlags']
const stdKeys = Object.keys(stdProperties)
const keysToAdd = Object.keys(c).filter(property => ![...stdKeys, ...ignoreCommandProperties].includes(property))
const additionalProperties: any = {}
Expand Down

0 comments on commit 3aea844

Please sign in to comment.