import del from "del" ; import * as fs from "fs" ; export namespace DirectoryUtil { export async function remove ( path ) { try { await del ( path ) ; } catch { } } export async function remake ( path ) { await remove ( path ) ; await fs . promises . mkdir ( path ) ; } export async function copy ( from , to ) { await remake ( to ) ; await _Copy ( from , to ) ; } async function _Copy ( from , to ) { const directory = await fs . promises . readdir ( from ) ; for ( const file of directory ) { const fromPath = `${ from }/${ file }` ; const toPath = `${ to }/${ file }` ; const stats = await fs . promises . stat ( fromPath ) ; if ( stats . isDirectory ( ) === true ) { await fs . promises . mkdir ( toPath ) ; await _Copy ( fromPath , toPath ) ; } else { const content = await fs . promises . readFile ( fromPath , "utf8" ) ; await fs . promises . writeFile ( toPath , content . split ( "\r\n" ) . join ( "\n" ) , "utf8" ) ; } } } }