Files
moeka-project/services/telegram-bot/src/utils/fs.ts
T
Neko de10f5ed8a feat(services/telegram): added bot (#8)
* feat: demo bot
* chore: update install
* refactor: rename
* refactor: adapt with new xsai
2025-01-15 22:45:55 +08:00

26 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
}