Skip to content

Commit

Permalink
feat(outdated): support table and list option on format option
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinyaigeek committed Nov 5, 2022
1 parent 2299772 commit 5d82338
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
12 changes: 8 additions & 4 deletions packages/plugin-commands-outdated/src/outdated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function rcOptionsTypes () {
], allTypes),
compatible: Boolean,
table: Boolean,
format: ['json'],
format: ['table', 'list', 'json'],
}
}

Expand Down Expand Up @@ -123,7 +123,7 @@ export type OutdatedCommandOptions = {
long?: boolean
recursive?: boolean
table?: boolean
format?: 'json'
format?: 'table' | 'list' | 'json'
} & Pick<Config,
| 'allProjects'
| 'ca'
Expand Down Expand Up @@ -192,8 +192,12 @@ export async function handler (

if (outdatedPackages.length === 0) return { output: '', exitCode: 0 }

if (opts.format === 'json') {
return { output: renderOutdatedJSON(outdatedPackages, opts), exitCode: 1 }
if (opts.format) {
switch (opts.format) {
case 'table': return { output: renderOutdatedTable(outdatedPackages, opts), exitCode: 1 }
case 'list': return { output: renderOutdatedList(outdatedPackages, opts), exitCode: 1 }
case 'json': return { output: renderOutdatedJSON(outdatedPackages, opts), exitCode: 1 }
}
}

if (opts.table !== false) {
Expand Down
8 changes: 6 additions & 2 deletions packages/plugin-commands-outdated/src/recursive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,12 @@ export async function outdatedRecursive (

if (isEmpty(outdatedMap)) return { output: '', exitCode: 0 }

if (opts.format === 'json') {
return { output: renderOutdatedJSON(outdatedMap, opts), exitCode: 1 }
if (opts.format) {
switch (opts.format) {
case 'table': return { output: renderOutdatedTable(outdatedMap, opts), exitCode: 1 }
case 'list': return { output: renderOutdatedList(outdatedMap, opts), exitCode: 1 }
case 'json': return { output: renderOutdatedJSON(outdatedMap, opts), exitCode: 1 }
}
}

if (opts.table !== false) {
Expand Down

0 comments on commit 5d82338

Please sign in to comment.