mirror of
https://github.com/moeru-ai/airi.git
synced 2026-05-20 09:40:33 +00:00
* tmp commit * now it works * fix: various of type and import issues * refactor: move test * refactor: rename with stage- prefix * refactor: all monorepo packages * refactor: fix all build * refactor: fix missing dep * fix: remove unnecessary deps * fix: netlify publish * fix: hf space deploy --------- Co-authored-by: LemonNeko <chheese048@gmail.com>
25 lines
441 B
TypeScript
25 lines
441 B
TypeScript
import { stat } from 'node:fs/promises'
|
|
|
|
export async function exists(path: string) {
|
|
try {
|
|
await stat(path)
|
|
return true
|
|
}
|
|
catch (error) {
|
|
if (isENOENTError(error))
|
|
return false
|
|
|
|
throw error
|
|
}
|
|
}
|
|
|
|
export function isENOENTError(error: unknown): boolean {
|
|
if (!(error instanceof Error))
|
|
return false
|
|
if (!('code' in error))
|
|
return false
|
|
if (error.code !== 'ENOENT')
|
|
return false
|
|
|
|
return true
|
|
}
|