import fs from 'fs' ; param file async function statAsync ( file ) { try { return await fs . promises . stat ( file ) ; } catch { return null ; } } export async function fileExistsAsync ( file ) { return ( await statAsync ( file ) ) ?. isFile ( ) ?? false ; } export async function directoryExistsAsync ( file ) { return ( await statAsync ( file ) ) ?. isDirectory ( ) ?? false ; } export function fileExists ( file ) { try { return fs . statSync ( file ) . isFile ( ) ; } catch ( e ) { return false ; } }