rsnext/packages/next/lib/file-exists.ts
2020-05-02 00:10:19 -04:00

13 lines
285 B
TypeScript

import { promises, constants } from 'fs'
export async function fileExists(fileName: string): Promise<boolean> {
try {
await promises.access(fileName, constants.F_OK)
return true
} catch (err) {
if (err.code === 'ENOENT') {
return false
}
throw err
}
}