import fs from 'fs' ; import { join } from 'path' ; param directoryPath export function recursiveRemove ( directoryPath ) { if ( fs . existsSync ( directoryPath ) && fs . lstatSync ( directoryPath ) . isDirectory ( ) ) { fs . readdirSync ( directoryPath ) . forEach ( element => { const filePath = join ( directoryPath , element ) ; if ( fs . lstatSync ( filePath ) . isDirectory ( ) ) { recursiveRemove ( filePath ) ; } else { fs . unlinkSync ( filePath ) ; } } ) ; fs . rmdirSync ( directoryPath ) ; } }