Files
moeka-project/scripts/fs.ts
T

19 lines
327 B
TypeScript

import { stat } from 'node:fs/promises'
export async function exists(path: string) {
try {
await stat(path)
return true
}
catch (error) {
if (!(error instanceof Error))
throw error
if (!('code' in error))
throw error
if (error.code !== 'ENOENT')
throw error
return false
}
}