Skip to content

Instantly share code, notes, and snippets.

@geedew
Last active February 3, 2021 12:36
Show Gist options
  • Select an option

  • Save geedew/cf66b81b0bcdab1f334b to your computer and use it in GitHub Desktop.

Select an option

Save geedew/cf66b81b0bcdab1f334b to your computer and use it in GitHub Desktop.

Revisions

  1. geedew renamed this gist Feb 11, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. geedew revised this gist Jan 25, 2015. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions node-rm-rf
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    var fs = require('fs');
    var deleteFolderRecursive = function(path) {
    if( fs.existsSync(path) ) {
    fs.readdirSync(path).forEach(function(file,index){
  3. geedew created this gist Jan 17, 2015.
    13 changes: 13 additions & 0 deletions node-rm-rf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    var deleteFolderRecursive = function(path) {
    if( fs.existsSync(path) ) {
    fs.readdirSync(path).forEach(function(file,index){
    var curPath = path + "/" + file;
    if(fs.lstatSync(curPath).isDirectory()) { // recurse
    deleteFolderRecursive(curPath);
    } else { // delete file
    fs.unlinkSync(curPath);
    }
    });
    fs.rmdirSync(path);
    }
    };