const addErrorCode = ( error , code ) => { ( error as any ) . code = code ; return error ; } ; export const createENOENT = ( path ) => { const error = new Error ( `no such file or directory: ${ path }` ) ; return addErrorCode ( error , 'ENOENT' ) ; } ; export const createENOTDIR = ( path ) => { const error = new Error ( `not a directory: ${ path }` ) ; return addErrorCode ( error , 'ENOTDIR' ) ; } ;