0
0
mirror of https://github.com/honojs/hono.git synced 2024-11-21 18:18:57 +01:00

fix(serve-static): silence NotFound warning on Deno (#3542)

fix(serve-static): silence `NotFound` warning on Deno
This commit is contained in:
Pablo Berganza 2024-10-22 06:40:07 +02:00 committed by GitHub
parent 15938b4896
commit 267186d65e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -4,7 +4,7 @@ import type { Env, MiddlewareHandler } from '../../types'
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const { open, lstatSync } = Deno
const { open, lstatSync, errors } = Deno
export const serveStatic = <E extends Env = Env>(
options: ServeStaticOptions<E>
@ -16,7 +16,9 @@ export const serveStatic = <E extends Env = Env>(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return file ? (file.readable as any) : null
} catch (e) {
console.warn(`${e}`)
if (!(e instanceof errors.NotFound)) {
console.warn(`${e}`)
}
}
}
const pathResolve = (path: string) => {