2020-05-02 06:10:19 +02:00
|
|
|
import { promises, constants } from 'fs'
|
2019-07-17 08:01:21 +02:00
|
|
|
|
|
|
|
export async function fileExists(fileName: string): Promise<boolean> {
|
|
|
|
try {
|
2020-05-02 06:10:19 +02:00
|
|
|
await promises.access(fileName, constants.F_OK)
|
2019-07-17 08:01:21 +02:00
|
|
|
return true
|
|
|
|
} catch (err) {
|
|
|
|
if (err.code === 'ENOENT') {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
throw err
|
|
|
|
}
|
|
|
|
}
|