Skip to content

Commit 1f6de93

Browse files
committed
fix: apply suggestion about check-package-exist
1 parent 73c4d84 commit 1f6de93

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

app/composables/npm/useSearch.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -339,18 +339,22 @@ export function useSearch(
339339
const { intent, name } = parseSuggestionIntent(q)
340340
let availability: { name: string; available: boolean } | null = null
341341

342+
const promises: Promise<void>[] = []
343+
342344
const trimmed = q.trim()
343345
if (isValidNewPackageName(trimmed)) {
344-
checkPackageExists(trimmed)
345-
.then(exists => {
346-
if (trimmed === toValue(query).trim()) {
347-
availability = { name: trimmed, available: !exists }
348-
packageAvailability.value = availability
349-
}
350-
})
351-
.catch(() => {
352-
availability = null
353-
})
346+
promises.push(
347+
checkPackageExists(trimmed)
348+
.then(exists => {
349+
if (trimmed === toValue(query).trim()) {
350+
availability = { name: trimmed, available: !exists }
351+
packageAvailability.value = availability
352+
}
353+
})
354+
.catch(() => {
355+
availability = null
356+
}),
357+
)
354358
} else {
355359
availability = null
356360
}
@@ -368,8 +372,6 @@ export function useSearch(
368372
const wantOrg = intent === 'org' || intent === 'both'
369373
const wantUser = intent === 'user' || intent === 'both'
370374

371-
const promises: Promise<void>[] = []
372-
373375
if (wantOrg && existenceCache.value[`org:${lowerName}`] === undefined) {
374376
promises.push(
375377
checkOrgNpm(name)

0 commit comments

Comments
 (0)