Skip to content

Commit af7f208

Browse files
committed
fix: render zero pkg and install size
1 parent 2baed3e commit af7f208

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

app/composables/usePackageComparison.ts

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -354,15 +354,17 @@ function computeFacetValue(
354354
}
355355
}
356356
case 'packageSize': {
357-
if (!data.packageSize) return null
357+
// A size of zero is valid
358+
if (data.packageSize == null) return null
358359
return {
359360
raw: data.packageSize,
360361
display: formatBytes(data.packageSize),
361362
status: data.packageSize > 5 * 1024 * 1024 ? 'warning' : 'neutral',
362363
}
363364
}
364365
case 'installSize': {
365-
if (!data.installSize) return null
366+
// A size of zero is valid
367+
if (data.installSize == null) return null
366368
return {
367369
raw: data.installSize.totalSize,
368370
display: formatBytes(data.installSize.totalSize),
@@ -372,7 +374,11 @@ function computeFacetValue(
372374
case 'moduleFormat': {
373375
if (!data.analysis) {
374376
if (isNoDependency)
375-
return { raw: 'up-to-you', display: t('compare.facets.values.up_to_you'), status: 'good' }
377+
return {
378+
raw: 'up-to-you',
379+
display: t('compare.facets.values.up_to_you'),
380+
status: 'good',
381+
}
376382
return null
377383
}
378384
const format = data.analysis.moduleFormat
@@ -393,7 +399,11 @@ function computeFacetValue(
393399
}
394400
if (!data.analysis) {
395401
if (isNoDependency)
396-
return { raw: 'up-to-you', display: t('compare.facets.values.up_to_you'), status: 'good' }
402+
return {
403+
raw: 'up-to-you',
404+
display: t('compare.facets.values.up_to_you'),
405+
status: 'good',
406+
}
397407
return null
398408
}
399409
const types = data.analysis.types
@@ -412,7 +422,11 @@ function computeFacetValue(
412422
const engines = data.metadata?.engines
413423
if (!engines?.node) {
414424
if (isNoDependency)
415-
return { raw: 'up-to-you', display: t('compare.facets.values.up_to_you'), status: 'good' }
425+
return {
426+
raw: 'up-to-you',
427+
display: t('compare.facets.values.up_to_you'),
428+
status: 'good',
429+
}
416430
return {
417431
raw: null,
418432
display: t('compare.facets.values.any'),
@@ -428,7 +442,11 @@ function computeFacetValue(
428442
case 'vulnerabilities': {
429443
if (!data.vulnerabilities) {
430444
if (isNoDependency)
431-
return { raw: 'up-to-you', display: t('compare.facets.values.up_to_you'), status: 'good' }
445+
return {
446+
raw: 'up-to-you',
447+
display: t('compare.facets.values.up_to_you'),
448+
status: 'good',
449+
}
432450
return null
433451
}
434452
const count = data.vulnerabilities.count
@@ -479,7 +497,7 @@ function computeFacetValue(
479497
}
480498
case 'dependencies': {
481499
const depCount = data.directDeps
482-
if (depCount === null) return null
500+
if (depCount == null) return null
483501
return {
484502
raw: depCount,
485503
display: String(depCount),
@@ -496,7 +514,6 @@ function computeFacetValue(
496514
status: isDeprecated ? 'bad' : 'good',
497515
}
498516
}
499-
// Coming soon facets
500517
case 'totalDependencies': {
501518
if (!data.installSize) return null
502519
const totalDepCount = data.installSize.dependencyCount

0 commit comments

Comments
 (0)