fix: args forwards compatibility
MODIFY
src/commands/readme.ts
src/commands/readme.ts
@@ -7,6 +7,7 @@ import {URL} from 'url'
import {castArray, compact, sortBy, template, uniqBy} from '../util'
import {HelpCompatibilityWrapper} from '../help-compatibility'
+import {ArgInput} from '@oclif/core/lib/interfaces'
const normalize = require('normalize-package-data')
const columns = Number.parseInt(process.env.COLUMNS!, 10) || 120
@@ -254,11 +255,13 @@ USAGE
return `[${name}]`
}
+ // v2 commands have args as an object, so we need to normalize it to an array for forwards compatibility
+ const normalized = (Array.isArray(command.args) ? command.args ?? [] : Object.values(command.args ?? {})) as ArgInput
const id = toConfiguredId(command.id, config)
const defaultUsage = () => {
return compact([
id,
- command.args.filter(a => !a.hidden).map(a => arg(a)).join(' '),
+ normalized.filter(a => !a.hidden).map(a => arg(a)).join(' '),
]).join(' ')
}

fix: args forwards compatibility