Skip to content

Instantly share code, notes, and snippets.

@ganeshh123
ganeshh123 / folder_delete.js
Last active August 18, 2020 21:21
Recursively Delete a folder and it's files in node, with an array of excluded files
let fileSystem = require('fs')
let path = require('path')
/* Returns true if folder is empty, false if not */
folder_empty = (path) => {
return fileSystem.readdirSync(path).length === 0;
}
/* Recursively Deletes a folder and it's contents */
// targetPath = absolute path of folder to be deleted