9609fe453d
* Replace deprecated fs.exists with fs.access. * Update packages/next/lib/file-exists.ts Co-Authored-By: Joe Haddad <timer150@gmail.com> * Update packages/next/lib/file-exists.ts Co-Authored-By: Joe Haddad <timer150@gmail.com>
16 lines
328 B
TypeScript
16 lines
328 B
TypeScript
import fs from 'fs'
|
|
import { promisify } from 'util'
|
|
|
|
const access = promisify(fs.access)
|
|
|
|
export async function fileExists(fileName: string): Promise<boolean> {
|
|
try {
|
|
await access(fileName, fs.constants.F_OK)
|
|
return true
|
|
} catch (err) {
|
|
if (err.code === 'ENOENT') {
|
|
return false
|
|
}
|
|
throw err
|
|
}
|
|
}
|