import * as fs from "fs-extra" ; import * as path from "path" ; export { createWriteStream } from "fs-extra" ; export function remove ( fsPath ) { return fs . remove ( fsPath ) ; } export async function directoryExists ( fsPath ) { try { const stats = await fs . stat ( fsPath ) ; return stats . isDirectory ( ) ; } catch ( err ) { if ( err . code === "ENOENT" ) { return false ; } throw err ; } } export async function fileExists ( fsPath ) { try { const stats = await fs . stat ( fsPath ) ; return stats . isFile ( ) ; } catch ( err ) { if ( err . code === "ENOENT" ) { return false ; } throw err ; } } export function ensureDir ( fsPath ) { return fs . ensureDir ( fsPath ) ; } export function readFile ( fsPath , encoding ) { return fs . readFile ( fsPath , encoding ) ; } export function readJsonFile ( fsPath ) { return fs . readJson ( fsPath ) ; } export function writeFile ( fsPath , content , encoding ? ) { return fs . writeFile ( fsPath , content , { encoding } ) ; } export function copy ( src , dest , options ? ) { const excludeList = options && options . exclude ? options . exclude . map ( ( f ) => path . join ( src , f ) . toLowerCase ( ) ) : [ ] ; const filter = ( filterSrc , _filterDest ) => { filterSrc = filterSrc . toLowerCase ( ) ; if ( excludeList . indexOf ( filterSrc ) >= 0 ) { return false ; } return true ; } ; return fs . copy ( src , dest , { filter } ) ; } export interface CopyOptions { exclude : string [ ] ; }