Skip to content

Commit cd1c10c

Browse files
committedNov 29, 2023
fix: correct sort order on interactive mode
1 parent 97b2a4a commit cd1c10c

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed
 

‎src/commands/check/interactive.ts

+7
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,20 @@ import readline from 'node:readline'
44
import process from 'node:process'
55
import c from 'picocolors'
66
import { createControlledPromise, notNullish } from '@antfu/utils'
7+
import { sort } from 'semver'
78
import type { CheckOptions, InteractiveContext, PackageMeta, ResolvedDepChange } from '../../types'
89
import { getVersionOfRange, updateTargetVersion } from '../../io/resolves'
910
import { getPrefixedVersion } from '../../utils/versions'
1011
import { FIG_BLOCK, FIG_NO_POINTER, FIG_POINTER, colorizeVersionDiff, createSliceRender, formatTable } from '../../render'
1112
import { timeDifference } from '../../utils/time'
13+
import { sortDepChanges } from '../../utils/sort'
1214
import { renderChanges } from './render'
1315

1416
export async function promptInteractive(pkgs: PackageMeta[], options: CheckOptions) {
17+
const {
18+
sort = 'diff-asc',
19+
} = options
20+
1521
pkgs.forEach((i) => {
1622
i.interactiveChecked = true
1723
i.resolved.forEach((i) => {
@@ -22,6 +28,7 @@ export async function promptInteractive(pkgs: PackageMeta[], options: CheckOptio
2228
updateTargetVersion(i, i.latestVersionAvailable, undefined, options.includeLocked)
2329
}
2430
})
31+
i.resolved = sortDepChanges(i.resolved, sort)
2532
})
2633

2734
if (!pkgs.some(i => i.resolved.some(i => i.update)))

‎src/commands/check/render.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ export function renderChanges(
7373
diffCounts[diff] = 0
7474
diffCounts[diff] += 1
7575
})
76+
77+
changes = sortDepChanges(changes, sort)
78+
7679
const diffEntries = Object.keys(diffCounts).length
7780
? Object.entries(diffCounts)
7881
.map(([key, value]) => `${c[DiffColorMap[key as DiffType || 'patch']](value)} ${key}`)
@@ -85,8 +88,6 @@ export function renderChanges(
8588
'',
8689
)
8790

88-
changes = sortDepChanges(changes, sort)
89-
9091
lines.push(...formatTable(
9192
changes.map(c => renderChange(c, interactive)),
9293
'LLRRRRRL',

0 commit comments

Comments
 (0)
Please sign in to comment.