Skip to content

Commit 72e364a

Browse files
committed
Add _id to the fallback for npmQuery
1 parent aedb072 commit 72e364a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/commands/optimize.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,12 @@ const lsByAgent = (() => {
192192
return ''
193193
}
194194
const names = new Set<string>()
195-
for (const { name, pkgid = '' } of pkgs) {
195+
for (const { _id, name, pkgid } of pkgs) {
196196
// `npm query` results may not have a "name" property, in which case we
197-
// fallback to "pkgid".
197+
// fallback to "_id" and then "pkgid".
198198
// `vlt ls --view json` results always have a "name" property.
199-
const resolvedName = name ?? pkgid.slice(0, pkgid.indexOf('@', 1))
199+
const fallback = _id ?? pkgid ?? ''
200+
const resolvedName = name ?? fallback.slice(0, fallback.indexOf('@', 1))
200201
if (resolvedName) {
201202
names.add(resolvedName)
202203
}

0 commit comments

Comments
 (0)