Skip to content

Commit

Permalink
fix: packageExists catch errors properly, close #1275
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Feb 6, 2024
1 parent 1eaf92a commit bdad035
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/slidev/node/utils.ts
Expand Up @@ -18,7 +18,7 @@ export async function resolveImportPath(importName: string, ensure: true): Promi
export async function resolveImportPath(importName: string, ensure?: boolean): Promise<string | undefined>
export async function resolveImportPath(importName: string, ensure = false) {
try {
return resolvePath(importName, {
return await resolvePath(importName, {
url: fileURLToPath(import.meta.url),
})
}
Expand All @@ -44,7 +44,7 @@ export async function resolveImportPath(importName: string, ensure = false) {

export async function resolveGlobalImportPath(importName: string): Promise<string> {
try {
return resolvePath(importName, {
return await resolvePath(importName, {
url: fileURLToPath(import.meta.url),
})
}
Expand Down Expand Up @@ -85,7 +85,7 @@ export function generateGoogleFontsUrl(options: ResolvedFontOptions) {
}

export async function packageExists(name: string) {
if (await resolveImportPath(`${name}/package.json`))
if (await resolveImportPath(`${name}/package.json`).catch(() => false))
return true
return false
}

0 comments on commit bdad035

Please sign in to comment.