import fs from 'fs' ; import { promisify } from 'util' ; export const writeFile = promisify ( fs . writeFile ) ; export const readFile = promisify ( fs . readFile ) ; export const mkdir = promisify ( fs . mkdir ) ; const fstat = ( filepath ) => { try { return fs . statSync ( filepath ) ; } catch ( e ) { return null ; } } ; export const fileExists = ( filepath ) : boolean => fstat ( filepath ) ?. isFile ( ) ?? false ; export const directoryExists = ( filepath ) : boolean => fstat ( filepath ) ?. isDirectory ( ) ?? false ;